noVNC/tests
Joel Martin c96f900336 Refactor keyboard event handling.
This is part of addressing issue #21 - non-US keyboard layouts.

There are several challenges when dealing with keyboard events:
  - The meaning and use of keyCode, charCode and which depends on
    both the browser and the event type (keyDown/Up vs keyPress).
  - We cannot automatically determine the keyboard layout
  - The keyDown and keyUp events have a keyCode value that has not
    been translated by modifier keys.
  - The keyPress event has a translated (for layout and modifiers)
    character code but the attribute containing it differs. keyCode
    contains the translated value in WebKit (Chrome/Safari), Opera
    11 and IE9. charCode contains the value in WebKit and Firefox.
    The which attribute contains the value on WebKit, Firefox and
    Opera 11.
  - The keyDown/Up keyCode value indicates (sort of) the physical
    key was pressed but only for standard US layout. On a US
    keyboard, the '-' and '_' characters are on the same key and
    generate a keyCode value of 189. But on an AZERTY keyboard even
    though they are different physical keys they both still
    generate a keyCode of 189!
  - To prevent a key event from propagating to the browser and
    causing unwanted default actions (such as closing a tab,
    opening a menu, shifting focus, etc) we must suppress this
    event in both keyDown and keyPress because not all key strokes
    generate on a keyPress event. Also, in WebKit and IE9
    suppressing the keyDown prevents a keyPress but other browsers
    still generated a keyPress even if keyDown is suppressed.

For safe key events, we wait until the keyPress event before
reporting a key down event. For unsafe key events, we report a key
down event when the keyDown event fires and we suppress any further
actions (including keyPress).

In order to report a key up event that matches what we reported
for the key down event, we keep a list of keys that are currently
down. When the keyDown event happens, we add the key event to the
list. If it is a safe key event, then we update the which attribute
in the most recent item on the list when we received a keyPress
event (keyPress should immediately follow keyDown). When we
received a keyUp event we search for the event on the list with
a matching keyCode and we report the character code using the value
in the 'which' attribute that was stored with that key.

For character codes above 255 we use a character code to keysym lookup
table. This is generated using the util/u2x11 script contributed by
Colin Dean (xvpsource.org).
2011-04-05 14:26:54 -05:00
..
arrays.html test/*.html: use "../include" instead of symlink. 2011-03-14 19:05:42 -05:00
arrays.js Clarify license on arrays test files. 2011-02-23 14:48:23 -06:00
base64.html test/*.html: use "../include" instead of symlink. 2011-03-14 19:05:42 -05:00
base64.js wsproxy.js: Fix multi-frame decoding. 2010-11-07 22:28:08 -06:00
canvas.html IE9 fixes: mouse, doctype. Adobe Flash link. 2011-03-29 15:44:03 -05:00
cursor.html test/*.html: use "../include" instead of symlink. 2011-03-14 19:05:42 -05:00
face.png API changes. Client cursor and settings menu. 2010-07-21 20:34:23 -05:00
face.png.js Various cross-browser fixes. 2010-06-23 16:08:36 -05:00
input.html Refactor keyboard event handling. 2011-04-05 14:26:54 -05:00
json2graph.py Clarify license on arrays test files. 2011-02-23 14:48:23 -06:00
stats.js Add Javascript binary byte array test. 2011-02-23 11:08:09 -06:00
vnc_perf.html IE9 fixes: mouse, doctype. Adobe Flash link. 2011-03-29 15:44:03 -05:00
vnc_playback.html IE9 fixes: mouse, doctype. Adobe Flash link. 2011-03-29 15:44:03 -05:00