noVNC/utils
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
..
Makefile Remove files that are now in websockify. 2011-01-12 20:31:04 -06:00
README.md Remove files that are now in websockify. 2011-01-12 20:31:04 -06:00
img2js.py Make scripts more compatible across OSes 2011-03-27 04:18:08 +08:00
launch.sh Make scripts more compatible across OSes 2011-03-27 04:18:08 +08:00
rebind wsproxy, wstelnet: wrap command, WS telnet client. 2011-01-12 13:15:11 -06:00
rebind.c wsproxy, wstelnet: wrap command, WS telnet client. 2011-01-12 13:15:11 -06:00
u2x11 Refactor keyboard event handling. 2011-04-05 14:26:54 -05:00
web.py Make scripts more compatible across OSes 2011-03-27 04:18:08 +08:00
websocket.py Make scripts more compatible across OSes 2011-03-27 04:18:08 +08:00
websockify Make scripts more compatible across OSes 2011-03-27 04:18:08 +08:00
wsproxy.py Remove files that are now in websockify. 2011-01-12 20:31:04 -06:00

README.md

WebSockets Proxy

wsproxy has become websockify. A copy of the python version of websockify (named wsproxy.py) is kept here for ease of use. The other versions of websockify (C, Node.js) and the associated test programs have been moved to websockify.

For more detailed description and usage information please refer to the websockify README.