4 ms·
Just a general advice for writing HTML games: remember to preventDefault() on all keyboard-related events (keydown, keypress) for all keys you use when your gam
by pornel 16y ago
Just a general advice for writing HTML games: remember to preventDefault() on all keyboard-related events (keydown, keypress) for all keys you use when your game has focus (add tabindex to your canvas so you'll get focus/blur events).
Otherwise browser's shortcuts could interfere with your game. I have Opera customized with 1-key shortcuts (with no modifier key) and that's a minefield in games that assume keyboard is all for them.
- mattdeboard 16y agoYeah, bummer. Hit X and the tab closed. Fun game though, kudos.
- bazookaBen 16y agohmm preventDefault() was not built into the older Operas. apparently the guys fixed preventDefault() on Opera 11.10, as explained here: http://impactjs.com/forums/help/binding-keys-in-opera-not-working http://impactjs.com/forums/help/binding-keys-in-opera-not-wo...
- pornel 16y agopreventDefault() worked in Opera since ancient times. However, Opera took default action on different event than other browsers (keydown instead of keypress if I remember correctly).