HTML and CSS Reference
In-Depth Information
Keyboard Input
In addition to the PointerEvent messages, the RFB protocol specifies that KeyEvent
messages indicate a key was pressed or released. The KeyEvent message is a binary event
message consisting of a message-type byte which specifies what kind of message is being
sent to the server (a keyboard event in this case), a down-flag byte that indicates if the key
is pressed when the value is 1 or if the key is now released if the value is 0, two bytes of
padding and the key itself specified in the four bytes of the key field. Figure 6-4 shows the
relationship between the keyboard input and the KeyEvent .
Figure 6-4. Pressing the 'T' key generates a binary KeyEvent message of 8 bytes
The RFB protocol uses the same key codes as the X Window System even if the client
(or server) is not running the X Window System. These codes are not the same as the key
codes on DOM KeyboardEvents, so a mapping function is necessary. Listing 6-16 shows
the KeyEvent function for our example.
Listing 6-16. The KeyEvent() Function
var doKeyEvent = function doKeyEvent($this, key, downFlag) {
var event = new CompositeStream();
event.appendBytes(4); // type (u8 4)
event.appendBytes(downFlag);
event.appendBytes(0,0); // padding
event.appendUint32(key);
sendBytes($this, event.consume(event.length));
}
 
Search WWH ::




Custom Search