If you make a manifest file and listen to the install event users can add your game to their home screen. Aka. PWA. Then you can listen to most keys! Works for chrome on desktop and all major mobile browsers. Safari don't have the install event and need to be "installed" manually
I have made a web editor that uses this. There is an example pwa app
Https://webide se/
I have made a web editor that uses this. There is an example pwa app Https://webide se/