linux/input.h 键码布局是否独立?
Are linux/input.h keycodes layout independent?
例如,在 input.h
中,KEY_D
等于 32。在 QWERTY 键盘上,D 是主行左数第三个 "printable" 键。在 DVORAK 键盘上,相同的键标记为 E。因此,如果我在 DVORAK 键盘上按 E,我会得到 KEY_D
(32) 还是 KEY_E
(18)?
您将获得KEY_D
。这些值是键的抽象,因为它们位于典型的物理键盘上(参见 ISO 9995), after abstracting from all interface details (see e.g. three PC scancode sets 和其他网格)。但这还没有考虑其他布局,既没有像 AZERTY 这样的国家布局,也没有像 Dvorak 这样的特殊布局。它们在下一层实现,其中独立的键码受修饰符影响并转换为结果字符串和事件。
USB "HID usage tables" document 明确表示:
Note
A general note on Usages and languages: Due to the variation of keyboards from language to language, it is not feasible to specify exact key mappings for every language. Where this list is not specific for a key function in a language, the closest equivalent key position should be used, so that a keyboard may be modified for a different language by simply printing different keycaps. One example is the Y key on a North American keyboard. In Germany this is typically Z. Rather than changing the keyboard firmware to put the Z Usage into that place in the descriptor list, the vendor should use the Y
Usage on both the North American and German keyboards. This continues to be the existing practice in the industry, in order to minimize the number of changes to the electronics to accommodate other languages.
因此,即使您的键盘最初是 Dvorak,您也会得到 KEY_D
。如果满足(大多数 XKB 布局源使用此表示法),您可以将其视为 "generic" KEY_C03
(再次参见 ISO9995 键名称)。
例如,在 input.h
中,KEY_D
等于 32。在 QWERTY 键盘上,D 是主行左数第三个 "printable" 键。在 DVORAK 键盘上,相同的键标记为 E。因此,如果我在 DVORAK 键盘上按 E,我会得到 KEY_D
(32) 还是 KEY_E
(18)?
您将获得KEY_D
。这些值是键的抽象,因为它们位于典型的物理键盘上(参见 ISO 9995), after abstracting from all interface details (see e.g. three PC scancode sets 和其他网格)。但这还没有考虑其他布局,既没有像 AZERTY 这样的国家布局,也没有像 Dvorak 这样的特殊布局。它们在下一层实现,其中独立的键码受修饰符影响并转换为结果字符串和事件。
USB "HID usage tables" document 明确表示:
Note A general note on Usages and languages: Due to the variation of keyboards from language to language, it is not feasible to specify exact key mappings for every language. Where this list is not specific for a key function in a language, the closest equivalent key position should be used, so that a keyboard may be modified for a different language by simply printing different keycaps. One example is the Y key on a North American keyboard. In Germany this is typically Z. Rather than changing the keyboard firmware to put the Z Usage into that place in the descriptor list, the vendor should use the Y Usage on both the North American and German keyboards. This continues to be the existing practice in the industry, in order to minimize the number of changes to the electronics to accommodate other languages.
因此,即使您的键盘最初是 Dvorak,您也会得到 KEY_D
。如果满足(大多数 XKB 布局源使用此表示法),您可以将其视为 "generic" KEY_C03
(再次参见 ISO9995 键名称)。