00:00
00:00
Newgrounds Background Image Theme

Someone gifted MetalSlayer69 supporter status!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Keyboard capture issue

597 Views | 2 Replies
New Topic Respond to this Topic

Keyboard capture issue 2023-03-15 15:44:24


I made a game using C++ SDL2 with Emscripten, zipped with an index.html file, and uploaded to NG. But, the keyboard keys are not recognized. Locally it runs fine with "emrun index.html" command. Why would that be?


I made the Newgrounds Mobile app, but it's gone now.

Response to Keyboard capture issue 2023-03-16 18:59:39


At 3/15/23 03:44 PM, NeWaGe wrote: I made a game using C++ SDL2 with Emscripten, zipped with an index.html file, and uploaded to NG. But, the keyboard keys are not recognized. Locally it runs fine with "emrun index.html" command. Why would that be?


You might get more responses in the programming forum. I haven't seen anyone here using emscripten. If you haven't already, you can check the console (F12) to see if it's throwing errors.

Response to Keyboard capture issue 2023-05-12 15:26:34 (edited 2023-05-12 15:26:53)


ok I figured it out. In case someone else comes across this thread...


In the HTML file, change the canvas element to: `<canvas class="emscripten" id="canvas" tabindex=1></canvas>` and add the script `document.getElementById('canvas').focus();`.


I made the Newgrounds Mobile app, but it's gone now.