Mailspring/src/keymap-utils.coffee
Ben Gotow 6ef0a49c26 fix(keymaps): Small tweaks to fix broken key behaviors
- Reload the menu after changing keymap sets
- Do not allow accelerators in the menu like "z", because they do not go through selector-based command matching and always fire into the window.
- Do not match `cmdctrl` to both `cmd` and `ctrl` on the Mac. Just `cmd`
- Re-order `shift-delete` mapping to `core:cut`, because it causes the menu to have no binding on Mac OS X
2015-11-13 16:05:40 -08:00

19 lines
483 B
CoffeeScript

KeymapUtils =
cmdCtrlPreprocessor: (keymap={}) ->
re = /(cmdctrl|ctrlcmd)/i
if process.platform is "darwin"
cmdctrl = 'cmd'
else
cmdctrl = 'ctrl'
for selector, keyBindings of keymap
normalizedBindings = {}
for keystrokes, command of keyBindings
keystrokes = keystrokes.replace(re, cmdctrl)
normalizedBindings[keystrokes] = command
keymap[selector] = normalizedBindings
return keymap
module.exports = KeymapUtils