I have javaScript code that listens to the "return" key pressed,
works on all browsers except webkit browsers.
I am aware of webkits recent changes to keyboard event handling.
I cant find the right solution in this detailed explanation.
here is the code.
function addEventHandler(node,type,fn){
if(typeof window.event !== "undefined"){
/* Internet Explorer way */
node.attachEvent( "on" + type, fn );
} else {
/* FF & Other Browsers */
node.addEventListener( type, fn,false );
}
}
function detectSubmit(){
searchTextInput = document.getElementById("txtSearch")
addEventHandler(searchTextInput,"keydown",triggerSearch);
}
function triggerSearch(e){
//getting the character that was pressed cross browser.
var key = e.keycode ? e.keycode : e.which;
//detect if the return key was pressed.
if(key==13){
alert("return clicked");
}
}
addEventHandler(window,"load",detectSubmit);