add event.getModifierString to convert hash into readable string
This commit is contained in:
parent
42a368ed02
commit
5783bae058
3 changed files with 16 additions and 3 deletions
|
|
@ -145,8 +145,8 @@ exports.handler = {
|
|||
if (hashId == -1 || hashId == 1 || hashId === 0 && key.length > 1) {
|
||||
if (cmds.inputBuffer.idle && startCommands[key])
|
||||
return startCommands[key];
|
||||
cmds.inputBuffer.push(editor, key);
|
||||
return {command: "null", passEvent: false};
|
||||
var isHandled = cmds.inputBuffer.push(editor, key);
|
||||
return {command: "null", passEvent: !isHandled};
|
||||
} // if no modifier || shift: wait for input.
|
||||
else if (key.length == 1 && (hashId === 0 || hashId == 4)) {
|
||||
return {command: "null", passEvent: true};
|
||||
|
|
|
|||
|
|
@ -217,6 +217,10 @@ var getModifierHash = useragent.isMac && useragent.isOpera && !("KeyboardEvent"
|
|||
return 0 | (e.ctrlKey ? 1 : 0) | (e.altKey ? 2 : 0) | (e.shiftKey ? 4 : 0) | (e.metaKey ? 8 : 0);
|
||||
};
|
||||
|
||||
exports.getModifierString = function(e) {
|
||||
return keys.KEY_MODS[getModifierHash(e)];
|
||||
};
|
||||
|
||||
function normalizeCommandKeys(callback, e, keyCode) {
|
||||
var hashId = getModifierHash(e);
|
||||
|
||||
|
|
|
|||
|
|
@ -133,6 +133,15 @@ var Keys = (function() {
|
|||
|
||||
// workaround for firefox bug
|
||||
ret[173] = '-';
|
||||
|
||||
(function() {
|
||||
var mods = ["cmd", "ctrl", "alt", "shift"];
|
||||
for (var i = Math.pow(2, mods.length); i--;) {
|
||||
ret.KEY_MODS[i] = mods.filter(function(x) {
|
||||
return i & ret.KEY_MODS[x];
|
||||
}).join("-") + "-";
|
||||
}
|
||||
})();
|
||||
|
||||
return ret;
|
||||
})();
|
||||
|
|
@ -140,6 +149,6 @@ oop.mixin(exports, Keys);
|
|||
|
||||
exports.keyCodeToString = function(keyCode) {
|
||||
return (Keys[keyCode] || String.fromCharCode(keyCode)).toLowerCase();
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue