commit
3e6d25c38f
2 changed files with 44 additions and 7 deletions
|
|
@ -226,6 +226,29 @@ function normalizeCommandKeys(callback, e, keyCode) {
|
|||
| (e.shiftKey ? 4 : 0) | (e.metaKey ? 8 : 0);
|
||||
}
|
||||
|
||||
if (!useragent.isMac && pressedKeys) {
|
||||
if (pressedKeys[91] || pressedKeys[92])
|
||||
hashId |= 8;
|
||||
if (pressedKeys.altGr) {
|
||||
if ((3 & hashId) != 3)
|
||||
pressedKeys.altGr = 0
|
||||
else
|
||||
return;
|
||||
}
|
||||
if (keyCode == 18 || keyCode == 17) {
|
||||
var location = e.location || e.keyLocation;
|
||||
if (keyCode == 17 && location == 1) {
|
||||
ts = e.timeStamp;
|
||||
} else if (keyCode == 18 && hashId == 3 && location == 2) {
|
||||
var dt = -ts;
|
||||
ts = e.timeStamp;
|
||||
dt += ts;
|
||||
if (dt < 3)
|
||||
pressedKeys.altGr = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (keyCode in keys.MODIFIER_KEYS) {
|
||||
switch (keys.MODIFIER_KEYS[keyCode]) {
|
||||
case "Alt":
|
||||
|
|
@ -244,23 +267,33 @@ function normalizeCommandKeys(callback, e, keyCode) {
|
|||
keyCode = 0;
|
||||
}
|
||||
|
||||
if (!useragent.isMac && pressedKeys[91] || pressedKeys[92])
|
||||
hashId |= 8;
|
||||
|
||||
if (hashId & 8 && (keyCode == 91 || keyCode == 93)) {
|
||||
keyCode = 0;
|
||||
}
|
||||
|
||||
if (!hashId && keyCode == 13) {
|
||||
if (e.keyLocation || e.location == 3) {
|
||||
callback(e, hashId, -keyCode)
|
||||
if (e.defaultPrevented)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// If there is no hashID and the keyCode is not a function key, then
|
||||
// If there is no hashId and the keyCode is not a function key, then
|
||||
// we don't call the callback as we don't handle a command key here
|
||||
// (it's a normal key/character input).
|
||||
if (!hashId && !(keyCode in keys.FUNCTION_KEYS) && !(keyCode in keys.PRINTABLE_KEYS)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return callback(e, hashId, keyCode);
|
||||
}
|
||||
|
||||
var pressedKeys = Object.create(null);
|
||||
var pressedKeys = null;
|
||||
var ts = 0;
|
||||
exports.addCommandKeyListener = function(el, callback) {
|
||||
var addListener = exports.addListener;
|
||||
if (useragent.isOldGecko || (useragent.isOpera && !("KeyboardEvent" in window))) {
|
||||
|
|
@ -298,9 +331,12 @@ exports.addCommandKeyListener = function(el, callback) {
|
|||
pressedKeys[e.keyCode] = null;
|
||||
});
|
||||
|
||||
addListener(el, "focus", function(e) {
|
||||
if (!pressedKeys) {
|
||||
pressedKeys = Object.create(null);
|
||||
});
|
||||
addListener(window, "focus", function(e) {
|
||||
pressedKeys = Object.create(null);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ var Keys = (function() {
|
|||
103: "Numpad7",
|
||||
104: "Numpad8",
|
||||
105: "Numpad9",
|
||||
'-13': "NumpadEnter",
|
||||
112: "F1",
|
||||
113: "F2",
|
||||
114: "F3",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue