This page demonstrates two techniques for detecting the shift, ctrl and alt keys. The first technique is as follows.
The second technique simply reads the event properties shiftKey, ctrlKey and altKey.
Experiment with your own browsers because the results may be OS-dependent.
Shift/ctrl/alt key events are logged here.
The following tests were made on Win2K.
Does not allow detection of the alt key.
Issues a keypress event between the keydown and keyup events when only the shift/ctrl/alt key is pressed - Moz and IE do not.
When a shift+key or ctrl+key is pressed, two keypress events occur between keydown and keyup.
Technique 1 can fail for the alt key when the menu is selected - because the keyup event is not seen.
The keypress event doesn't fire at all when a ctrl+key combo is pressed. It does in Op and Moz.
Technique 1 can fail for the alt key when the menu is selected - because the keyup event is not seen.
Added the second technique and did more tests.
By your use of X and/or CBE and/or any Javascript from this site you consent to the GNU LGPL - please read it. If you have any questions about the license, read the FAQ and/or come to the forums.
Forum support is available at the X Library Support Forums.