KeyEvents - takaha/noVNC GitHub Wiki

Here are some notes about noVNC keyboard event handling.

Keyboard Events Across Browsers

The following table is a list of keyboard events across different browsers in the order that they happen for different keyboard input/actions. This assumes that in keyDown, special keys have their default action stopped and are prevented from bubbling (this stops the keyPress event in Webkit and IE9).

Input
Action
Webkit (Chrome/Safari) Firefox 4.0 (and 3.6) Opera 11 IE 9
's' D: 83 / 0 / 83
P: 115 / 115 / 115
U: 83 / 0 / 83
D: 83 / 0 / 83
P: 0 / 115 / 115
U: 83 / 0 / 83
D: 83 / u / 83
P: 115 / u / 115
U: 83 / u / 83
D: 83 / u / u
P: 115 / u / u
U: 83 / u / u
F4 D: 115 / 0 / 115
P: ---------------
U: 115 / 0 / 115
D: 115 / 0 / 115
P: 115 / 0 / 0
U: 115 / 0 / 115
D: 115 / u / 115
P: 115 / u / 0
U: 115 / u / 115
D: 115 / u / u
P: ---------------
U: 115 / u / u
Ctrl-C D: 17 / 0 / 17
D: 67 / 0 / 67
P: ---------------
U: 67 / 0 / 67
U: 17 / 0 / 17
D: 17 / 0 / 17
D: 67 / 0 / 67
P: 0 / 99 / 99
U: 67 / 0 / 67
U: 17 / 0 / 17
D: 17 / u / 17
D: 67 / u / 67
P: 99 / u / 99
U: 67 / u / 67
U: 17 / u / 17
D: 17 / u / u
D: 67 / u / 67
P: ---------------
U: 67 / u / 67
U: 17 / u / 17

Legend:

D:    = keyDown event
P:    = keyPress event
U:    = keyUp event
k/c/w = keyCode / charCode / which
u     = undefined value

Useful browser keyboard event links:

Simple Keyboard Events Test

Using the noVNC tests/input.html page, type the following key combinations:

's'
F4
Ctrl-C
'-'
Insert

This should result in the following in the messages box (less the blank lines). The values in parens can vary between browsers, but the keysym values should be identical.

1: keyPress down keysym: 115 (key: 0, char: 115, which: 115)
2: keyPress  up  keysym: 115 (key: 83, char: 0, which: 83)

3: keyPress down keysym: 65473 (key: 115, char: 0, which: 115)
4: keyPress  up  keysym: 65473 (key: 115, char: 0, which: 115)

5: keyPress down keysym: 65507 (key: 17, char: 0, which: 17)
6: keyPress down keysym: 99 (key: 67, char: 0, which: 67)
7: keyPress  up  keysym: 99 (key: 67, char: 0, which: 67)
8: keyPress  up  keysym: 65507 (key: 17, char: 0, which: 17)

9: keyPress down keysym: 45 (key: 0, char: 45, which: 45)
10: keyPress  up  keysym: 45 (key: 109, char: 0, which: 109)

11: keyPress down keysym: 65379 (key: 45, char: 0, which: 45)
12: keyPress  up  keysym: 65379 (key: 45, char: 0, which: 45)

In the same test page, type the following key combinations. There should not be any default browser reponse to them. For example, Ctrl-W should not close the tab and Alt-F should not activate a browser menu.

Ctrl-W
Alt-F

The resulting messages output should look like this:

13: keyPress down keysym: 65507 (key: 17, char: 0, which: 17)
14: keyPress down keysym: 119 (key: 87, char: 0, which: 87)
15: keyPress  up  keysym: 119 (key: 87, char: 0, which: 87)
16: keyPress  up  keysym: 65507 (key: 17, char: 0, which: 17)
17: keyPress down keysym: 65513 (key: 18, char: 0, which: 18)
18: keyPress down keysym: 102 (key: 70, char: 0, which: 70)
19: keyPress  up  keysym: 102 (key: 70, char: 0, which: 70)
20: keyPress  up  keysym: 65513 (key: 18, char: 0, which: 18)

All Ctrl key combinations should be properly suppressed across all browsers and operating systems. In Opera, the Alt key combinations cannot be properly suppressed. In Windows, all browsers seem to have trouble properly suppressing Alt key combinations. Chrome is best with a beep sound, other browsers open a Window. a beep

⚠️ **GitHub.com Fallback** ⚠️