Logo (klik voor homepage)
 
!HID User Manual - KeyCode

The KeyCode in more detail
The KeyCode is a 32-bit number, represented in hexacimal format (8 digits) and can be entered directly in the Edit key definition window. The KeyCode consists of 4 parts (from right to left):

  • The actual key value (0-255), shown in
yellow
  • The Group to which the key belongs (0-127), shown in
blue
  • The global Usage for the key (0-255), shown in
green
  • The state of the modifiers (0-255), shown in
red
  

Key value
The rightmost part of the KeyCode is the actual key value (0-255). Applications should always consider the complete KeyCode, rather than just the key value, as the same key value can be used in a different Group or Usage.

Group
On a USB keyboard more than the usual 256 keys may be available and keys have therefore been sub-divided into groups. The following groups are currently recognised in the Consumer Control usage class:

Group Name Description
00 Standard control These are system-wide controls, such as Play, Stop and Volume control.
01 Applications Laucher (AL) They keys are generally meant to start an application or open a new document in an editor.
02 Application control (AC) These keys are meant to control certain features within the current application.
0f Vendor-specific These keys can be used for anything as they have no predetermined meaning.
Usage
The second part of the KeyCode describes the global usage for that key. At present the following Usages will be recognised:

Usage Name Description
01 Generic Desktop Controls These keys have a system-wide use, such as the Sleep and PowerDown key.
07 Keyboard These are the standard keyboard keys. There are not processed by !HID, unless; one of the GUI keys are held down at the same time.; The behaviour of the GUI keys can be set in Choices...
09 Buttons These are the mouse buttons. The first three buttons (Select, Menu and Adjust); are already handled by RISC OS and are therefore not processed by !HID.; Any extra buttons may be reported if they are set to Special key code; in the mouse section in Choices...
0c Consumer Control This is the most common class of special keys. Most of the extra keys on a modern keyboard fall into this Usage.; It allows applications to be launched and features within an application to be controlled.
ff Vendor Specific Certain keys on some keyboards (in particular Microsoft) will generate; Vendor Specific key codes. A key definition file can be set up; in the Auto directory within !HID to give such keys a sensible name.; Several examples are supplied.
Modifiers
Each keyboard has a number of modifier keys. These are keys that, when pressed, can modify the use of another key. The most common modifiers are the Control, Shift and Alt keys. Most keyboards today also have a GUI key, often referred to as the Windows key as most keyboards have the Windows logo on the key top. GUI stands for Graphical User Interface, so it could just as well be Apple, Acorn or Iyonix. There are 8 modifiers on the keyboard, 4 on either side. Each key represents one bit of the modifier byte.

Bit Description
0 L Control
1 L Shift
2 L Alt
3 L GUI
4 R Control
5 R Shift
6 R Alt
7 R GUI
The modifier byte is constructed of 2 nibbles, each of which describes one side of the keyboard. You may want to ORR the two nibbles together, in order to be able to use the keys at either side of the keyboard. If such behaviour is wanted, it is the task of a helper program to ORR the nibbles. The keyboard driver should always report the exact above bit pattern.

Related subjects

Klik voor homepage © Copyright Paul Reuvers X-Ample Technology bv  usb@xat.nl Last changed: Last changed: Monday, 12 April 2004 - 22:01 CET.