Disable IE browser HotKeys Function with JavaScript

I was creating a program simulation training in Lectora, which use most of the function keys on the keyboard during the process. Hot keys on IE browser are assigned with their default function, such as F1=help, F3=search, F5=refresh, F11=full screen.

In order to override these function in Lectora and assign them with your own designated function, you will need the following:


1. html Keycode reference table -

http://protocolsofmatrix.blogspot.com/2007/09/javascript-keycode-reference-table-for.html

2. Turn on "Show HTML published object names in object properties" in Lectora Preference, General tab.


Now you are ready to get to work.

On the page where you need to simulate the function key press event, add a new "External HTML Object", code as follow:



--- Here is the breakdown ---

KeyCode == 115


is for F4 key;

trivNextPage (' ', true);


is go to next page;

window.event.keyCode = 000;----is to disable the default F4 function;

so this script is to tell the program on key press of F4, go to next page.


--- Change to other functions ---

If you replace the line where trivNextPage (' ', true); to

og22689.actionShow();


is to show (object name) on key press, you can get the html code of the object from object property.


--- Important Note ---

You cannot use the Lectora action for the same keystrock at the same time while you are using the JavaScript to disable the default function, you must place the lectora action in JavaScript format within the same script. Unless you are trying to simulate F1 key press.


--- F1 Key Press ---

Add an Lectora Keystroke action to F1 for (whatever action you want to do).

Add a new "External HTML Object" with script below to disable the F1 help menu pop up window:




Hope this will help reduce your headache if you want to create some simulation exercises with hotkeys. I am open for any suggestion to improve the script. Thank you!

Discussion (1)

This is an interesting piece of code. I can see how disabling an F-Key may be necessary for some simulation projects. Has this been achieved with other browsers, by the way?

Discussions have been disabled for this post