noVNC/include
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
..
web-socket-js Update web-socket-js to bb5797cad. 2011-03-16 10:33:01 -05:00
base64.js JSLint. 2010-09-08 10:11:11 -05:00
black.css Fix CSS sizes with HTML5 doctype. 2011-02-02 10:48:29 -06:00
canvas.js Fix focus/clipboard related to mouse/keyboard refactor. 2011-04-03 17:51:47 -05:00
des.js include/des.js: trim some fat. 2010-09-30 11:17:52 -05:00
input.js Refactor keyboard event handling. 2011-04-05 14:26:54 -05:00
logo.js Add logo, favicon. 2011-02-03 11:04:32 -06:00
plain.css Fix CSS sizes with HTML5 doctype. 2011-02-02 10:48:29 -06:00
playback.js playback.js: move to include/ for easier reference. 2010-09-22 16:55:06 -05:00
rfb.js Fix focus/clipboard related to mouse/keyboard refactor. 2011-04-03 17:51:47 -05:00
ui.js Fix focus/clipboard related to mouse/keyboard refactor. 2011-04-03 17:51:47 -05:00
util.js API change: Mouse/kbd handling to include/input.js 2011-04-03 17:30:45 -05:00
vnc.js API change: Mouse/kbd handling to include/input.js 2011-04-03 17:30:45 -05:00
websock.js Update web-socket-js to bb5797cad. 2011-03-16 10:33:01 -05:00
webutil.js Fix strict mode complaints in firefox 4. 2011-01-16 18:57:45 -06:00