keyevent - Javascript: escape key clears text in firefox -


i have input type text functionality. text has focus in meantime text can change. when press escape key should close. did bind key event , works fine. problem in firefox text clears when pressing escape key. can test here:

$('#asd').click(function() {     $(this).val('huhu'); });  $('#asd').keydown(function(e) {     if(e.which == 27) {         e.preventdefault();         return false;     } }); 

http://jsfiddle.net/hj9th/1/

click in textfield , press escape. text disappears. tried prevent it's not working.

what can prevent that?

super dirty guess i'm using that:

$('#asd').click(function() {     $(this).val('huhu'); });  $('#asd').keydown(function(e) {     if(e.which == 27) {         var $this = $(this);         $this.blur();         settimeout(function() {             $this.focus();         }, 10);     } }); 

http://jsfiddle.net/hj9th/2/


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -