Stylus Studio XML Editor

Table of contents

Appendices

A.1 Introduction

Introduction

Each keyboard event references a key using a DOMString key identifier. The set contained in this appendix is based on the sets of keycodes from:

  • the interface java.awt.event.KeyEvent of the Java 2 Platform v1.4 [KeyEvent];

  • the enumeration System.Windows.Forms.Keys of the Microsoft .NET Framework 1.0 [Keys].

While implementations are recommended to use the most relevant identifier for a key independently of the platform or keyboard layout mappings, DOM applications should not make assumption on the ability of keyboard devices to generate them. When using keyboard events, "consider using numbers and function keys (F4, F5, and so on) instead of letters in shortcut-key combinaisons" ([DWW95]) given that most keyboard layouts will provide keys for those.

"U+000000", "U+000001", ..., "U+FFFFFF" are Unicode based key identifiers ([Unicode30]). When a key cannot be mapped to Unicode, a specific identifier is used (see also [Guidelines for defining key identifiers]). In any case, no assumption should be made between the sequence of keyboard events and the text events. The following three examples illustrated the concept of keyboard layout mappings and its relation with keyboard events.

The keystroke "U+000051" (Latin Capital Letter Q key) will produce (on a PC/AT US keyboard using a US keyboard layout mapping and without any modifier activated) the Unicode character q (Latin Small Letter Q):

  1. {"http://www.w3.org/2001/xml-events", "keydown"}: "U+000051" (Latin Capital Letter Q key)

  2. {"http://www.w3.org/2001/xml-events", "textInput"}: "q"

  3. {"http://www.w3.org/2001/xml-events", "keyup"}: "U+000051" (Latin Capital Letter Q key)

If the keyboard layout mapping is switched to a french mapping, pressing the same key will produce:

  1. {"http://www.w3.org/2001/xml-events", "keydown"}: "U+000041"

  2. {"http://www.w3.org/2001/xml-events", "textInput"}: "a"

  3. {"http://www.w3.org/2001/xml-events", "keyup"}: "U+000041"

If the keyboard layout mapping is switched to a serbian (cyrillic) mapping, pressing the same key will produce:

  1. {"http://www.w3.org/2001/xml-events", "keydown"}: "U+000409"

  2. {"http://www.w3.org/2001/xml-events", "textInput"}: "љ"

  3. {"http://www.w3.org/2001/xml-events", "keyup"}: "U+000409"

NOTE: 

The order between the text event and keyboard events may differ depending on the keyboard devices.

Modifier keys[top]

Modifier keys

Keyboard input use modifier keys to change the normal behavior of a key. The KeyboardEvent interface provides specific attributes for them: KeyboardEvent.ctrlKey, KeyboardEvent.shiftKey, KeyboardEvent.altKey, KeyboardEvent.metaKey, and KeyboardEvent.altGraphKey.

The following example describes a possible sequence of keys to generate the Unicode character Q (Latin Capital Letter Q) on a PC/AT US keyboard using a US mapping:

  1. {"http://www.w3.org/2001/xml-events", "keydown"}: "Shift", shiftKey

  2. {"http://www.w3.org/2001/xml-events", "keydown"}: "U+000051" (Latin Capital Letter Q key), shiftKey

  3. {"http://www.w3.org/2001/xml-events", "textInput"}: "Q"

  4. {"http://www.w3.org/2001/xml-events", "keyup"}: "U+000051" (Latin Capital Letter Q key), shiftKey

  5. {"http://www.w3.org/2001/xml-events", "keyup"}: "Shift"

The following example describes a possible sequence of keys that does not generate a Unicode character (using the same configuration):

  1. {"http://www.w3.org/2001/xml-events", "keydown"}: "Control", ctrlKey

  2. {"http://www.w3.org/2001/xml-events", "keydown"}: "U+000056" (Latin Capital Letter V key), ctrlKey

  3. {"http://www.w3.org/2001/xml-events", "keyup"}: "U+000056" (Latin Capital Letter V key), ctrlKey

  4. {"http://www.w3.org/2001/xml-events", "keyup"}: "Control"

Dead keys[top]

Dead keys

Keyboard input use dead keys for the input of composed character sequences. Unlike the handwriting sequence, in which users type the base character first, keyboard input require to enter a special state when a dead key is pressed and emit the character(s) only when one of a limited number of "legal" base character is entered.

The dead keys are represented in the key identifiers set using combining diacritical marks. The sequence of keystrokes "U+000302" (Combining Circumflex Accent key) and "U+000045" (Latin Capital Letter E key) will likely produce (on a PC/AT french keyboard using a french mapping and without any modifier activated) the Unicode character é (Latin Small Letter E With Acute) or the composed Unicode character sequence e (Latin Small Letter E) and 000302 (Combining Circumflex Accent). In practice, french keyboard input will generate the Unicode character é instead of the composed Unicode character sequence, as shown in the following example:

  1. {"http://www.w3.org/2001/xml-events", "keydown"}: "U+000302" (Combining Circumflex Accent key)

  2. {"http://www.w3.org/2001/xml-events", "keyup"}: "U+000302" (Combining Circumflex Accent key)

  3. {"http://www.w3.org/2001/xml-events", "keydown"}: "U+000045" (Latin Capital Letter E key)

  4. {"http://www.w3.org/2001/xml-events", "textInput"}: "é"

  5. {"http://www.w3.org/2001/xml-events", "keyup"}: "U+000045" (Latin Capital Letter E key)

Input Method Editors[top]

Input Method Editors

Also known as front end processor, an input method editor (IME) is an application that performs the conversion between keystrokes and ideographs or other characters, usually by user-guided dictionary lookup.

The IMEs function keys are not represented in this set. As an example, receiving an keydown for the "Accept" key identifier does not necessarily implies that the text currently selected in the IME is being accepted. It only indicates that a keystroke happened, disconnected from the IME Accept functionality. Depending on the device in use, the IME Accept functionality can be obtain using the Accept key or the Return key. Keyboard events cannot be used to determine the current state of the input method editor.

Keyboard events correspond to the events generated by the input device after the keyboard layout mapping but before the processing of the input method editor.

The following example describes a possible sequence of keys to generate the Unicode character し (Hiragana Letter SI) using Japanese input methods. This assumes that the input method editor is activated and in the Japanese-Romaji input mode. The keys "Convert" and "Accept" may be replaced by others depending on the input device in use and the configuration of the IME, e.g. it could be respectively "U+000020" (Space key) and "Enter".

  1. {"http://www.w3.org/2001/xml-events", "keydown"}: "U+000053" (Latin Capital Letter S key)

  2. {"http://www.w3.org/2001/xml-events", "keyup"}: "U+000053" (Latin Capital Letter S key)

  3. {"http://www.w3.org/2001/xml-events", "keydown"}: "U+000049" (Latin Capital Letter I key)

  4. {"http://www.w3.org/2001/xml-events", "keyup"}: "U+000049" (Latin Capital Letter I key)

  5. {"http://www.w3.org/2001/xml-events", "keydown"}: "Convert"

  6. {"http://www.w3.org/2001/xml-events", "keyup"}: "Convert"

  7. {"http://www.w3.org/2001/xml-events", "keydown"}: "Accept"

  8. {"http://www.w3.org/2001/xml-events", "textInput"}: "し"

  9. {"http://www.w3.org/2001/xml-events", "keyup"}: "Accept"

NOTE: 

This specification does not provide a representation of the input method editor (IME) events, e.g. representing the input context.

Guidelines for defining key identifiers[top]

Guidelines for defining key identifiers
NOTE: 

This section is informative.

The list of key identifiers contained in this appendix is not exhaustive and input devices may have to define their own key identifiers. Here is a algorithm to determine which key identifier to use:

  1. Determine a representation for the key by looking at the keyboard layout mapping in use (and not the keyboard device in use). This representation should be unique, as human friendly as possible, platform independent, and consistent. For example, on PC/AT US keyboards with a US mapping, the 'Q' key is mapped to the key identifier "U+000051" (Latin Capital Letter Q key), the '1/!' key is mapped to the key identifier "U+000031" (Digit One key), the key '`/~' is mapped to the key identifier "U+000060" (Grave Accent key), and the 'Enter' key is mapped to the key identifier "Enter".

  2. Find an appropriate mapping in the Unicode character set. There might not always be an appropriate and obvious mapping: the Unicode set contains characters and symbols, the key might generate different characters depending on the operating system, ... In general, unless the representation of the key can be mapped to a unique Unicode character, it is better to create a new one.

  3. If no appropriate mapping was found, create an key identifier as human friendly as possible. As an example, the Enter key is mapped to the key identifier "Enter" and not to "U+00000A" (Line Feed), given that this key generates the character 00000A on Unix operating systems and the characters 00000D and 00000A on Windows operating systems.