preventEvent( event )
This function cancels an event and prevents it from bubbling up.
Parameters:
event ā reference to the event to cancel
Example:
The following can be used on the onkeydown event to restrict which keys can be pressed.Ā
function gradeKeys(event, element) {
Ā var key = event.keyCode;
Ā switch (key) {
Ā Ā case 65: // allow A
Ā Ā case 66: // allow B
Ā Ā case 67: // allow C
Ā Ā case 68: // allow D
Ā Ā case 70: // allow F
Ā Ā case 8: // allow backspace
Ā Ā case 46: // allow delete
Ā Ā case 37: // allow left arrow
Ā Ā case 39: // allow right arrow
Ā Ā case 40: // allow down arrow
Ā Ā case 38: // allow up arrow
Ā Ā case 13: // allow enter
Ā Ā Ā break;
Ā Ā default: // disallow all other keys
Ā Ā Ā preventEvent(event);
Ā }Ā
}
, multiple selections available,