Friday, June 01, 2007

Capturing F1 in javascript

Developing Web applications for IE may require to custom action instead of the popup of Windows Internet Explorer Help.

OnKeyPress doesn't gets fired when pressing functional keys, however, we are able to capture F1 by inserting the following script:

<script language="javascript">
document.onhelp = function()
{
alert("help"); // instead of an alert you can define custom content
return false; // necessary for cancel original F1 event
}
</script>

No comments: