do not throw error for key-chains (e.g Ctrl-B Command-Up)

This commit is contained in:
nightwing 2013-03-05 00:03:11 +04:00
commit 01b7c4a866

View file

@ -121,10 +121,14 @@ function HashHandler(config, platform) {
var key = typeof binding == "string" ? binding: binding[this.platform];
this.bindKey(key, command);
};
// accepts keys in the form ctrl+Enter or ctrl-Enter
// keys without modifiers or shift only
// accepts keys in the form ctrl+Enter or ctrl-Enter
// keys without modifiers or shift only
this.parseKeys = function(keys) {
// todo support keychains
if (keys.indexOf(" ") != -1)
keys = keys.split(/\s+/).pop();
var parts = keys.toLowerCase().split(/[\-\+]([\-\+])?/).filter(function(x){return x});
var key = parts.pop();
@ -139,8 +143,11 @@ function HashHandler(config, platform) {
var hashId = 0;
for (var i = parts.length; i--;) {
var modifier = keyUtil.KEY_MODS[parts[i]];
if (modifier == null)
throw "invalid modifier " + parts[i] + " in " + keys;
if (modifier == null) {
if (typeof console != "undefined")
console.error("invalid modifier " + parts[i] + " in " + keys);
return false;
}
hashId |= modifier;
}
return {key: key, hashId: hashId};