I am using Phaser 2.2.2 to develop a typing game and there is method called:
game.input.keyboard.addKeyCapture(/*[array of keycodes]*/);
This worked with Space(no page scrolling), dot, comma dash(dash with a caused one webpage backward) but didn't work with single quote as I can still open Quick Find with it i.e the browser still detects the shortcut. This method prevents the bubbling state of the key when pressed to propagate to the browser, i.e the browser does not detect a keypress.
I also found this beautiful typing application which disables completely keyboard shortcuts, like magic: https://typing.io/ No additional configuration or installing addons or plugins.
How can I achieve this in my Phaser game as well? Should I put some third party JS libraries.
Ah and btw is this tool for the job: https://github.com/jeresig/jquery.hotkeys
The onkeydown event occurs when the user is pressing a key, you can prevent it using returing false:
Use:
document.onkeydown = function (e) {
return false;
}