< input type = " text " onfocus = " javascript:onFocus(this); " > < script language = " javascript " > function onFocus(entity) ... { var isie = (document.all) ? true : false; entity.onkeypress = onKeypress; if (!isie)...{ document.captureEvents(Event.KEYPRESS); } } function onKeypress(e) ... { var isie = (document.all) ? true : false; var key; if (isie) key = window.event.keyCode; else key = e.which; alert(key); } </ script >