I can successfully stop all keystrokes:
$this.keydown(false);
How to disable all keys except backspace key?
Check the keyCode the event argument:
keyCode
$this.keydown(function(e) { if(e.keyCode !== 8) { e.preventDefault(); } });
Here is a demo.
Use a callback, check the key code of the pressed key if it is a backspace key, and then enable it, otherwise block it.