I want to detect and block certain keyboard shortcuts on a web page. For example, say I want to prevent alt+tab for switching apps (just an example, assume any global shortcut).
Here's as far as I can think it out:
- attach a keyboard event listener to
document
(orwindow
?) - use
event.which
to check which key combination was pressed - if it was a blacklisted shortcut, stop the browser from executing it
But, I don't know how to
A) detect multiple keys (e.g. alt and tab together), or
B) stop them from executing (can I just return false
?).
Can anyone tell me how to accomplish the above?