loss of keyboard input when clicking outside canvas

590 views
Skip to first unread message

TheBlackSword

unread,
Jan 26, 2016, 9:59:50 PM1/26/16
to emscripten-discuss
Hi, I recently used Emscripten to compile a C++/SDL project that I had written into Javascript and deploy it to the web. For the most part, it seems to be working perfectly (atleast in Mozilla Firefox) except that when I embed it in a webpage, I permanently lose keyboard input if I click outside the canvas. I do not lose mouse input. I'm fairly new to HTML5/Javascript, and I am no expert with Emscripten, so I was wondering if anyone had any idea how I could fix this.  

Alon Zakai

unread,
Jan 27, 2016, 2:08:09 PM1/27/16
to emscripten-discuss
Emscripten's SDL bindings might automatically capture keyboard events, which does not let the rest of the page receive them.

Is this with SDL1 or 2?

On Tue, Jan 26, 2016 at 6:59 PM, TheBlackSword <blacksworde...@gmail.com> wrote:
Hi, I recently used Emscripten to compile a C++/SDL project that I had written into Javascript and deploy it to the web. For the most part, it seems to be working perfectly (atleast in Mozilla Firefox) except that when I embed it in a webpage, I permanently lose keyboard input if I click outside the canvas. I do not lose mouse input. I'm fairly new to HTML5/Javascript, and I am no expert with Emscripten, so I was wondering if anyone had any idea how I could fix this.  

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

TheBlackSword

unread,
Jan 27, 2016, 2:49:39 PM1/27/16
to emscripten-discuss
SDL1
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

Alon Zakai

unread,
Jan 27, 2016, 3:11:33 PM1/27/16
to emscripten-discuss
SDL1 does capture keyboard events by default. Look at SDL_Init where it calls addEventListener. You can set doNotCaptureKeyboard on Module to not capture it at all, or keyboardListeningElement to make it listen on a specific HTML element (which would still allow events to reach other places on the page).

https://github.com/kripken/emscripten/blob/master/src/library_sdl.js#L1298

To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.

Ian Krueger

unread,
Jan 27, 2016, 3:29:53 PM1/27/16
to emscripte...@googlegroups.com
Thank you. 

You received this message because you are subscribed to a topic in the Google Groups "emscripten-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/emscripten-discuss/BOcw1FNKjyg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to emscripten-disc...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages