do not throw error for key-chains (e.g Ctrl-B Command-Up)
This commit is contained in:
parent
c653abf969
commit
01b7c4a866
1 changed files with 12 additions and 5 deletions
|
|
@ -121,10 +121,14 @@ function HashHandler(config, platform) {
|
||||||
var key = typeof binding == "string" ? binding: binding[this.platform];
|
var key = typeof binding == "string" ? binding: binding[this.platform];
|
||||||
this.bindKey(key, command);
|
this.bindKey(key, command);
|
||||||
};
|
};
|
||||||
|
|
||||||
// accepts keys in the form ctrl+Enter or ctrl-Enter
|
// accepts keys in the form ctrl+Enter or ctrl-Enter
|
||||||
// keys without modifiers or shift only
|
// keys without modifiers or shift only
|
||||||
this.parseKeys = function(keys) {
|
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 parts = keys.toLowerCase().split(/[\-\+]([\-\+])?/).filter(function(x){return x});
|
||||||
var key = parts.pop();
|
var key = parts.pop();
|
||||||
|
|
||||||
|
|
@ -139,8 +143,11 @@ function HashHandler(config, platform) {
|
||||||
var hashId = 0;
|
var hashId = 0;
|
||||||
for (var i = parts.length; i--;) {
|
for (var i = parts.length; i--;) {
|
||||||
var modifier = keyUtil.KEY_MODS[parts[i]];
|
var modifier = keyUtil.KEY_MODS[parts[i]];
|
||||||
if (modifier == null)
|
if (modifier == null) {
|
||||||
throw "invalid modifier " + parts[i] + " in " + keys;
|
if (typeof console != "undefined")
|
||||||
|
console.error("invalid modifier " + parts[i] + " in " + keys);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
hashId |= modifier;
|
hashId |= modifier;
|
||||||
}
|
}
|
||||||
return {key: key, hashId: hashId};
|
return {key: key, hashId: hashId};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue