There are various ways to trap keys in Firefox and IE. Apparently Firefox and IE have different ways of trapping the F1 key and prevent the default application help.
After quite a bit of research, I came up with the following code that will work both in Firefox and IE. The following example uses Yahoo's event library, however, you can code in original DOM easily:
if (!YAHOO.util.Event.addListener(document, "keydown", fnCallback)) alert("failed");
document.onhelp = new Function("return false;"); // disable default help in IE
function fnCallback(evt) {
if ( evt == null )
evt = event;
if ( evt.keyCode == 112 ) //F1
{
alert("la"); // put your action here! IMPORTANT: must come before evt.preventDefault()!
evt.preventDefault(); // disable default help in Firefox
return false;
}
}
</script>
</head>
<body id="body1">
</body>
</html>
YUI ( Yahoo UI Library ) 를 사용해서 제어하는 방법이다.
(소스 코드태의 : build/yahoo/yahoo.js)