Default prevention of 'ctrl pageup' and 'ctrl pagedown' in Chrome

I have code for creating hotkeys for a web application. All hotkeys work in IE and Firefox, however Ctrl + PgUp and Ctrl + PgDn do not work in Chrome.

After overturning the answers and writing some custom test code, I believe that I decided that this is because these events fire, in Chrome, when the keyboard is activated instead of keydown.

By default, Chrome handlers for these events run instead of mine (or at least the first one), as well as switching the browser to the next or previous tab. If I use a hotkey to switch back to the tab with my application, my handlers will catch the event.

So my question is: is there a way to catch these events in Chrome and prevent the default functionality from starting up?

This code:

//These work in IE and Firefox $(this).bind('keydown', 'ctrl+pageup', (evt) => { this.prevPage(); return false; }); $(this).bind('keydown', 'ctrl+pagedown', (evt) => { this.nextPage(); return false; }); //These catch the event in chrome, but it too late $(this).bind('keyup', 'ctrl+pageup', (evt) => { this.prevPage(); return false; }); $(this).bind('keyup', 'ctrl+pagedown', (evt) => { this.nextPage(); return false; }); 

It does exactly what I want in IE and Firefox, but not in Chrome. I tried evt.preventDefault() , evt.stopImmediatePropagation and evt.stopPropagation . However, this does not work (I believe because my handlers are called after the browser handlers).

+6
source share
1 answer

Check a similar question at this link:

Chrome - Javascript prevents default behavior Ctrl + MouseWheel

They say that this is impossible on chrome and is still being solved!

0
source

All Articles