Problem with Opera and jquery keydown return false
Question
I´m trying this on Opera 10 and doesn´t work:
$('input').keydown(function(){ return false; });
This works fine in other browsers.
Can anybody tell me something about this??
Thanks!
Solution
See the key events compatibility table. Opera does not cancel a keypress when keydown
preventsDefault. Use the keypress
event instead to cancel keyboard input.
(Although, this is rarely a good idea. Intercepting keypresses does not stop a field being changed by other means than keys, for example drag and drop. Set the readonly or disabled properties true to properly stop the value being changed.)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow