commit 4ba7b8ec517c095eba6c742f2e1ecdbaafb92a2e from: James Cook date: Mon Jan 17 22:12:08 2022 UTC Suppress default keyboard handlers. commit - 388ebd57548f5437bef752b02a095eafe1afa9aa commit + 4ba7b8ec517c095eba6c742f2e1ecdbaafb92a2e blob - b91fc2a4262b55c619ae046d2e475f7324c30256 blob + e8ab39124bd0030966bca2f9105917694a3182c7 --- src/S3D/WebUI.idr +++ src/S3D/WebUI.idr @@ -46,13 +46,15 @@ getGl2Context canvas = handleKeyDown : IORef UIState -> Event -> JSIO () handleKeyDown stateRef event = - do keyboardEvent <- unMaybe "cast keyboard event" $ pure (safeCast event) + do preventDefault event + keyboardEvent <- unMaybe "cast keyboard event" $ pure (safeCast event) theKey <- Web.Raw.UIEvents.KeyboardEvent.key keyboardEvent modifyIORef stateRef $ { keysDown $= insert theKey } handleKeyUp : IORef UIState -> Event -> JSIO () handleKeyUp stateRef event = - do keyboardEvent <- unMaybe "cast keyboard event" $ pure (safeCast event) + do preventDefault event + keyboardEvent <- unMaybe "cast keyboard event" $ pure (safeCast event) theKey <- Web.Raw.UIEvents.KeyboardEvent.key keyboardEvent modifyIORef stateRef $ { keysDown $= delete theKey }