From 62568d19f4f426daa07af7844f908aded6ca687d Mon Sep 17 00:00:00 2001 From: Ian Flanigan Date: Sun, 21 Aug 2022 21:37:03 +0200 Subject: [PATCH] Prevent the default action when the Apple keyboard handles a key (#151) Before, if the browser window wasn't tall enough to show the whole keyboard, using the arrow keys in the window would cause the page to move as well. Now all key events that are sent to the keyboard have `preventDefault()` called on them. --- js/components/Keyboard.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/js/components/Keyboard.tsx b/js/components/Keyboard.tsx index 4b38861..98aafcc 100644 --- a/js/components/Keyboard.tsx +++ b/js/components/Keyboard.tsx @@ -118,9 +118,7 @@ export const Keyboard = ({ apple2, e }: KeyboardProps) => { if (document.activeElement && document.activeElement !== document.body) { return; } - if (event.key === ' ') { - event.preventDefault(); - } + event.preventDefault(); const key = mapKeyEvent(event, active.includes('LOCK')); if (key !== 0xff) { // CTRL-SHIFT-DELETE for reset