Extend keyboard handling

To cope with the Mac’s “meta” key (ie command/⌘) preparatory to
trapping command-S
This commit is contained in:
Jermolene
2014-09-02 10:41:48 +01:00
parent 44228ed9f7
commit b25351e834
2 changed files with 11 additions and 4 deletions

View File

@@ -48,6 +48,8 @@ exports.parseKeyDescriptor = function(keyDescriptor) {
info.shiftKey = true;
} else if(s === "alt") {
info.altKey = true;
} else if(s === "meta") {
info.metaKey = true;
}
// Replace named keys with their code
if(namedKeys[s]) {
@@ -57,4 +59,12 @@ exports.parseKeyDescriptor = function(keyDescriptor) {
return info;
};
exports.checkKeyDescriptor = function(event,keyInfo) {
return event.keyCode === keyInfo.keyCode &&
event.shiftKey === keyInfo.shiftKey &&
event.altKey === keyInfo.altKey &&
event.ctrlKey === keyInfo.ctrlKey &&
event.metaKey === keyInfo.metaKey;
};
})();