@@ 169,11 169,30 @@ window.addEventListener("load", async () => {
augroup END`).split("\n").map(command => ["nvim_command", [command]]));
});
+ let pressingAltGr = false;
+ keyHandler.addEventListener("keyup", (evt) => {
+ if (evt.key === "Alt" && evt.location === 2) {
+ pressingAltGr = false;
+ }
+ })
keyHandler.addEventListener("keydown", (evt) => {
keyHandler.style.left = `0px`;
keyHandler.style.top = `0px`;
- // Note: order of this array is important, we need to check OS before checking metaa
+ // Special case AltRight: both AltLeft and AltRight cause keyevents
+ // to have their `altKey` attribute set to true, but only AltLeft
+ // events should be treated as special keys.
+ if (evt.key === "Alt" && evt.location === 2) {
+ pressingAltGr = true;
+ }
+ // This shouldn't be necessary thanks to the keyup event handler
+ // but just to make sure, we reset pressingAltGr when no alt key is
+ // pressed.
+ if (!evt.altKey) {
+ pressingAltGr = false;
+ }
+
+ // Note: order of this array is important, we need to check OS before checking meta
const specialKeys = [["Alt", "A"], ["Control", "C"], ["OS", "D"], ["Meta", "D"]];
// The event has to be trusted and either have a modifier or a non-literal representation
if (evt.isTrusted
@@ 182,7 201,7 @@ window.addEventListener("load", async () => {
evt.key !== mod && (evt as any).getModifierState(mod)))) {
const text = specialKeys.concat(["Shift", "S"])
.reduce((key: string, [attr, mod]: [string, string]) => {
- if ((evt as any).getModifierState(attr)) {
+ if ((evt as any).getModifierState(attr) && (attr !== "Alt" || !pressingAltGr)) {
return addModifier(mod, key);
}
return key;
@@ 11,6 11,7 @@
"limit": 120
}
],
+ "no-big-function": false,
"no-conditional-assignment": false,
"no-console": false,
"no-namespace": false,