jQuery Hotkeys "Tab" on Chrome will still insert \t character, even after return false -


suppose have 2 code below, 1 uses alert() 1 doesn't. found in chrome, 1 using alert() insert tab character \t textarea.

$(function() {   $("textarea").bind("keydown", "tab", function() {     alert("something");     return false;   });    $("textarea").bind("keydown", "shift+tab", function() {     this.value = "don't alert()";     return false;   });  }); 

http://jsfiddle.net/tu6vf/4/

why happening? , how can prevent behaviour (adding of tab character after return false)

you can try use code before "return false"

if(jquery.browser.msie) {     event.cancelbubble = true; } else {     event.stoppropagation(); }    

you need add parameter event in each binding :

function(event) { ... } 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -