diff --git a/src/js/selection/SelectionManager.js b/src/js/selection/SelectionManager.js index 2a7f2e3f..633b2f39 100644 --- a/src/js/selection/SelectionManager.js +++ b/src/js/selection/SelectionManager.js @@ -19,7 +19,7 @@ $.subscribe(Events.SELECTION_MOVE_REQUEST, $.proxy(this.onSelectionMoved_, this)); pskl.app.shortcutService.addShortcut('ctrl+V', this.paste.bind(this)); - pskl.app.shortcutService.addShortcut('shift+V', this.pasteOpaqueOnly.bind(this)); + pskl.app.shortcutService.addShortcut('ctrl+shift+V', this.pasteOpaqueOnly.bind(this)); pskl.app.shortcutService.addShortcut('ctrl+X', this.cut.bind(this)); pskl.app.shortcutService.addShortcut('ctrl+C', this.copy.bind(this)); pskl.app.shortcutService.addShortcut('del', this.erase.bind(this)); diff --git a/src/js/service/keyboard/ShortcutService.js b/src/js/service/keyboard/ShortcutService.js index ca921e81..49e07c68 100644 --- a/src/js/service/keyboard/ShortcutService.js +++ b/src/js/service/keyboard/ShortcutService.js @@ -47,20 +47,31 @@ }; ns.ShortcutService.prototype.parseKey_ = function (key) { - var meta = 'normal'; - if (key.indexOf('ctrl+') === 0) { - meta = 'ctrl'; - key = key.replace('ctrl+', ''); - } else if (key.indexOf('shift+') === 0) { - meta = 'shift'; - key = key.replace('shift+', ''); - } else if (key.indexOf('alt+') === 0) { - meta = 'alt'; - key = key.replace('alt+', ''); - } + var meta = this.getMetaKey_({ + alt : key.indexOf('alt+') != -1, + shift : key.indexOf('shift+') != -1, + ctrl : key.indexOf('ctrl+') != -1 + }); + + var parts = key.split('+'); + key = parts[parts.length-1]; return {meta : meta, key : key}; }; + ns.ShortcutService.prototype.getMetaKey_ = function (meta) { + var keyBuffer = []; + ['alt', 'ctrl', 'shift'].forEach(function (metaKey) { + if (meta[metaKey]) { + keyBuffer.push(metaKey); + } + }); + + if (keyBuffer.length > 0) { + return keyBuffer.join('+'); + } else { + return 'normal'; + } + }; /** * @private */ @@ -73,16 +84,12 @@ var keyShortcuts = this.shortcuts_[charkey]; if(keyShortcuts) { - var cb; - if (this.isCtrlKeyPressed_(evt)) { - cb = keyShortcuts.ctrl; - } else if (this.isShiftKeyPressed_(evt)) { - cb = keyShortcuts.shift; - } else if (this.isAltKeyPressed_(evt)) { - cb = keyShortcuts.alt; - } else { - cb = keyShortcuts.normal; - } + var meta = this.getMetaKey_({ + alt : this.isAltKeyPressed_(evt), + shift : this.isShiftKeyPressed_(evt), + ctrl : this.isCtrlKeyPressed_(evt) + }); + var cb = keyShortcuts[meta]; if(cb) { var bubble = cb(charkey);