mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-14 17:52:55 +00:00
Specifying keybindings that use a command key (⌘ on Mac, Ctrl on Win/Linux) using the appropriate Mac binding, e.g. '⌘Z'. Use iD.ui.cmd to translate it to an appropriate key string for other platforms, e.g. 'Ctrl+Z'.
23 lines
524 B
JavaScript
23 lines
524 B
JavaScript
// Translate a MacOS key command into the appropriate Windows/Linux equivalent.
|
|
// For example, ⌘Z -> Ctrl+Z
|
|
iD.ui.cmd = function(code) {
|
|
if (iD.detect().os === 'mac')
|
|
return code;
|
|
|
|
var modifiers = {
|
|
'⌘': 'Ctrl',
|
|
'⇧': 'Shift',
|
|
'⌥': 'Alt'
|
|
}, keys = [];
|
|
|
|
for (var i = 0; i < code.length; i++) {
|
|
if (code[i] in modifiers) {
|
|
keys.push(modifiers[code[i]]);
|
|
} else {
|
|
keys.push(code[i]);
|
|
}
|
|
}
|
|
|
|
return keys.join('+');
|
|
};
|