cykod / Quintus

HTML5 Game Engine
http://html5quintus.com
GNU General Public License v2.0
1.41k stars 401 forks source link

option to allow browser shortcut keys #108

Closed EvanBurchard closed 10 years ago

EvanBurchard commented 10 years ago

When playing a game, not being able to switch tabs or refresh the page while the game has focus is pretty sensible. In development, it's a bit cumbersome.

It would be nice if there was an easy hook to toggle the "e.preventDefault()" lines inside of the "enableKeyboard" function declaration of quintus_input.js.

Currently, I'm just commenting out those lines in development. Autodetecting a production vs. dev mode seems like overkill. Ideally, I'd just set this option somewhere in my game file. Maybe something like Q.input.allowDefaultKeyBehavior = true; or something.

cykod commented 10 years ago

Agreed - maybe just a toggle that only eats the bound keys (i.e. if you have 'left' and 'right' bound - eat those, otherwise let them be)

ghost commented 10 years ago

I put a conditional on the keydown event to allow shortcuts with the Ctrl key: https://github.com/Bitshock/Quintus/commit/15e9c25d92b9afb7233a5b4735d0e6cdeb3583fe