Created
July 16, 2012 14:40
-
-
Save mteece/3123080 to your computer and use it in GitHub Desktop.
Prevent BACKSPACE (requires jQuery).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Prevent BACKSPACE | |
$(document).keydown(function(e) { | |
if (e.target.type !== 'textarea') { | |
var code = e.keyCode || e.which; | |
if (code === 8) { //BACKSPACE keycode | |
//e.cancelBubble is supported by IE - this will kill the bubbling process. | |
e.cancelBubble = true; | |
e.returnValue = false; | |
//e.stopPropagation works only in Firefox. | |
if (e.stopPropagation) { | |
e.stopPropagation(); | |
e.preventDefault(); | |
} | |
return false; | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@brandonhenricks, fork, don't comment ;)