Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Commit

Permalink
✨ Synchronise modifiers on physical and virtual kb
Browse files Browse the repository at this point in the history
Close #440
  • Loading branch information
GitSquared committed Feb 24, 2019
1 parent b00b12c commit e5517fa
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/classes/keyboard.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,13 @@ class Keyboard {
this.keydownHandler = e => {
// See #330
if (e.getModifierState("AltGraph")) return;

// See #440
if (e.code === "ShiftLeft" || e.code === "ShiftRight") this.container.dataset.isShiftOn = true;
if (e.code === "AltLeft" || e.code === "AltRight") this.container.dataset.isAltOn = true;
if (e.code === "CapsLock" && !this.container.dataset.isCapsLckOn) this.container.dataset.isCapsLckOn = true;
if (e.code === "CapsLock" && this.container.dataset.isCapsLckOn) this.container.dataset.isCapsLckOn = false;

let key = findKey(e);
if (key === null) return;
if (key.length) {
Expand All @@ -243,6 +250,11 @@ class Keyboard {
document.onkeyup = e => {
// See #330
if (e.key !== "AltGraph" && e.getModifierState("AltGraph")) return;

// See #440
if (e.code === "ShiftLeft" || e.code === "ShiftRight") this.container.dataset.isShiftOn = false;
if (e.code === "AltLeft" || e.code === "AltRight") this.container.dataset.isAltOn = false;

let key = findKey(e);
if (key === null) return;
if (key.length) {
Expand Down

0 comments on commit e5517fa

Please sign in to comment.