Wednesday, 3 December 2008

How do I handle or abort Function Key events (e.g. F1, F2,etc) in both IE and Firefox?

Run this page and you will be shown the keycode for the Function Key you pressed. In addition, any standard browser handlers (such as help prompts when F1 is pressed or Searches when F3 is pressed) will be aborted - so you can pass them to your app instead. See below:


<script type="text/javascript" language="javascript">
/////////////////////////////////////////////////////////////////////
///Demo Script to display the function key that was pressed
///and abort any browser event e.g. F3 for IE find,
///F1 for IE help, F1 for Firefox Help
/////////////////////////////////////////////////////////////////////
///Version Author Date Comment
///1.0 DDK 03 Dec 2008 Original Version for
/// Application Tender
/// Proof of concept
/// when users wanted 'green
/// screen' functionality
/////////////////////////////////////////////////////////////////////
//debugger;
document.onkeydown = showDownAndAbortEvent;
//Stop F1 opening Help in IE
document.onhelp=function() {return false};
window.onhelp=function() {return false};

// decipher key down codes
function showDownAndAbortEvent(evt)
{
//clearCells();
evt = (evt) ? evt : ((event) ? event : null);
if (evt) {
alert('keyCode:' + evt.keyCode + ';charcode' + evt.charCode + ';' ) ;
try
{
evt.preventDefault(); // disable default help in Firefox
evt.stopPropagation();
}
catch (ex) {}
try
{
//Kill any intercepts for ie
window.event.cancelBubble = true;
window.event.returnValue = false;
window.event.keyCode = 0;
}
catch (ex) {}
return false;
}
}
</script>

6 comments:

Stivyx said...

Great script! Works for me (IE v6 & v7, Firefox v2 & v3, Ghrome).

Salvador said...

A written finished order is sent to an independent expert who write my annotated bibliography fully analyzes and makes a final conclusion regarding the compliance of the work with the topic, the stated requirements and generally accepted design standards.

Chad said...

Every well-written custom paper contains quality and unique thesis statement https://writemypapers.company/coursework-writing-service/ . Our writers draw up a thesis statement after research has been made.

Rodrigo said...

You can find fix for this problem here: https://urbanmatter.com/best-mastercard-casino-online-in-canada/

777bet said...

I just had to share my fantastic experience with bet999.io . It's been an absolute game-changer for me, and I felt compelled to let you all know.

First of all, the user interface is super user-friendly. I was able to navigate the site with ease, even as a newcomer to online betting. They've got a wide range of sports and events to bet on, so there's something for everyone.

Redot said...

If you want byu bitcoin you can check here how it is do