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

Commit

Permalink
fix: errors when using arrow keys on a touchscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
GitSquared committed May 6, 2021
1 parent fd39b0b commit ea75972
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/classes/keyboard.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ class Keyboard {
this.container.addEventListener("touchstart", e => {
e.preventDefault();
for (let i = 0; i < e.changedTouches.length; i++) {
let key = e.changedTouches[i].target.offsetParent;
let key = e.changedTouches[i].target.parentElement;
if (key.tagName === 'svg') key = key.parentElement;
if (key.getAttribute("class").startsWith("keyboard_key")) {
key.setAttribute("class", key.getAttribute("class")+" active");
key.onmousedown({preventDefault: () => {return true}});
Expand All @@ -236,7 +237,8 @@ class Keyboard {
let dropKeyTouchHandler = e => {
e.preventDefault();
for (let i = 0; i < e.changedTouches.length; i++) {
let key = e.changedTouches[i].target.offsetParent;
let key = e.changedTouches[i].target.parentElement;
if (key.tagName === 'svg') key = key.parentElement;
if (key.getAttribute("class").startsWith("keyboard_key")) {
key.setAttribute("class", key.getAttribute("class").replace("active", ""));
key.onmouseup({preventDefault: () => {return true}});
Expand Down

0 comments on commit ea75972

Please sign in to comment.