Match the location of the Alt key to the activated Apple key

Modern browsers set the 'location' property on keyboard events when
the key is located in several places. The ALT key, for example, can be
either on the left or the right side of the keyboard.

This change uses the location to determine which Apple key to
activate, if it is available, and defaults to the old behavior if not.
This commit is contained in:
Ian Flanigan 2019-01-04 00:32:56 +01:00
parent 8ee8b01d0a
commit ef74dddfae

View File

@ -823,8 +823,12 @@ function _keydown(evt) {
} else if (evt.keyCode == 91 || evt.keyCode == 93) { // Command } else if (evt.keyCode == 91 || evt.keyCode == 93) { // Command
keyboard.commandKey(true); keyboard.commandKey(true);
} else if (evt.keyCode == 18) { // Alt } else if (evt.keyCode == 18) { // Alt
if (evt.originalEvent.location == 1) {
keyboard.commandKey(true);
} else {
keyboard.optionKey(true); keyboard.optionKey(true);
} }
}
} }
function _keyup(evt) { function _keyup(evt) {
@ -838,8 +842,12 @@ function _keyup(evt) {
} else if (evt.keyCode == 91 || evt.keyCode == 93) { // Command } else if (evt.keyCode == 91 || evt.keyCode == 93) { // Command
keyboard.commandKey(false); keyboard.commandKey(false);
} else if (evt.keyCode == 18) { // Alt } else if (evt.keyCode == 18) { // Alt
if (evt.originalEvent.location == 1) {
keyboard.commandKey(false);
} else {
keyboard.optionKey(false); keyboard.optionKey(false);
} }
}
} }
function updateScreen() { function updateScreen() {