mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 09:12:52 +00:00
36 lines
791 B
JavaScript
36 lines
791 B
JavaScript
import { utilDetect } from '../util/detect';
|
|
|
|
|
|
// Translate a MacOS key command into the appropriate Windows/Linux equivalent.
|
|
// For example, ⌘Z -> Ctrl+Z
|
|
export function uiCmd(code) {
|
|
var detected = utilDetect();
|
|
|
|
if (detected.os === 'mac') {
|
|
return code;
|
|
}
|
|
|
|
if (detected.os === 'win') {
|
|
if (code === '⌘⇧Z') return 'Ctrl+Y';
|
|
}
|
|
|
|
var result = '',
|
|
replacements = {
|
|
'⌘': 'Ctrl',
|
|
'⇧': 'Shift',
|
|
'⌥': 'Alt',
|
|
'⌫': 'Backspace',
|
|
'⌦': 'Delete'
|
|
};
|
|
|
|
for (var i = 0; i < code.length; i++) {
|
|
if (code[i] in replacements) {
|
|
result += replacements[code[i]] + '+';
|
|
} else {
|
|
result += code[i];
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|