Block browser shortcuts
In certain cases, we want to pre-empt the browser shortcuts so that they do not perform the default option.
Note: this pre-emption offers no guarantees. The browsers retain control of this behaviour.
Example:
Alt+F4: Firefox authorises pre-emption and makes it possible to block closing. Chrome systematically intercepts the Alt+F4 first and closes straight away.
Implement shortcut blocking
In the header_footer fragment add the call to shortcut.block(Key); or shortcut.block(Change[+Change..]+Key); or shortcut.block(Change[+Change..]+Key,Options):
<jsp:attribute name="head_footer"> <script type="text/javascript"> require(["dojo/domReady!"], function() { // interception of the browser's standard shortcut keys to invalidate the default behaviour shortcut.block("F1"); shortcut.block("F2"); shortcut.block("F3"); shortcut.block("F4"); shortcut.block("F5"); shortcut.block("F6"); shortcut.block("F7"); shortcut.block("F8"); shortcut.block("F9"); shortcut.block("F10"); shortcut.block("F11"); shortcut.block("F12");
shortcut.block("Ctrl+F5"); shortcut.block("Ctrl+A",{'disable_in_input':true}); shortcut.block("Backspace",{'disable_in_input':true}); }); </script> </jsp:attribute>
|
The valid "change" elements are:
Ctrl
Alt
Shift
Meta
The valid Key elements are:
All alphanumerical characters a..z, 0..9
All special characters accessible from a standard keyboard
Special keys:
- Tab
- Space
- Return
- Enter
- Backspace
- Scroll_lock
- Caps_lock
- Num_lock
- Pause
- Insert
- Home
- Delete
- End
- Page_up
- Page_down
- Left
- Up
- Right
- Down
- F1
- F2
- F3
- F4
- F5
- F6
- F7
- F8
- F9
- F10
- F11
- F12
The original code is at the following address: http://www.openjs.com/scripts/events/keyboard_shortcuts/.