-
Notifications
You must be signed in to change notification settings - Fork 388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CLDR-17140 kbd: specify modifier matching #3314
Changes from all commits
d356cac
3a7b21e
2420114
ecbdcbb
afd3ab1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,6 +90,9 @@ The LDML specification is divided into the following parts: | |
* [Element: scanCodes](#Element_scanCodes) | ||
* [Element: layers](#Element_layers) | ||
* [Element: layer](#Element_layer) | ||
* [Layer Modifier Components](#layer-modifier-components) | ||
* [Modifier Left- and Right- keys](#modifier-left--and-right--keys) | ||
* [Layer Modifier Matching](#layer-modifier-matching) | ||
* [Element: row](#Element_row) | ||
* [Element: variables](#Element_variables) | ||
* [Element: string](#element-string) | ||
|
@@ -201,8 +204,6 @@ Keyboard use can be challenging for individuals with various types of disabiliti | |
|
||
**Arrangement:** The relative position of the rectangles that represent keys, either physically or virtually. A hardware keyboard has a static arrangement while a touch keyboard may have a dynamic arrangement that changes per language and/or layer. While the arrangement of keys on a keyboard may be fixed, the mapping of those keys may vary. | ||
|
||
**Base character:** The character emitted by a particular key when no modifiers are active. In ISO terms, this is group 1, level 1. | ||
|
||
**Base character:** The character emitted by a particular key when no modifiers are active. In ISO 9995-1:2009 terms, this is Group 1, Level 1. | ||
|
||
**Core keys:** also known as “alphanumeric” section. The primary set of key values on a keyboard that are used for typing the target language of the keyboard. For example, the three rows of letters on a standard US QWERTY keyboard (QWERTYUIOP, ASDFGHJKL, ZXCVBNM) together with the most significant punctuation keys. Usually this equates to the minimal set of keys for a language as seen on mobile phone keyboards. | ||
|
@@ -1358,7 +1359,7 @@ A `layer` element describes the configuration of keys on a particular layer of a | |
**Syntax** | ||
|
||
```xml | ||
<layer id="layerId" modifier="{Set of Modifier Combinations}"> | ||
<layer id="layerId" modifiers="{Set of Modifier Combinations}"> | ||
... | ||
</layer> | ||
``` | ||
|
@@ -1380,46 +1381,88 @@ _Attribute_ `id` (required for `touch`) | |
> | ||
> Must match `[A-Za-z0-9][A-Za-z0-9-]*` | ||
|
||
_Attribute:_ `modifier` (required for `hardware`) | ||
_Attribute:_ `modifiers` (required for `hardware`) | ||
|
||
> This has two roles. It acts as an identifier for the `layer` element for hardware keyboards (in the absence of the id= element) and also provides the linkage from the hardware modifiers into the correct `layer`. | ||
> | ||
> To indicate that no modifiers apply, the reserved name of `none` is used. | ||
> The following modifier components can be used, separated by spaces. | ||
> Note that `L` or `R` indicates a left- or right- side modifier only (such as `altL`) | ||
> whereas `alt` indicates _either_ left or right alt key (that is, `altL` or `altR`). `ctrl` indicates either left or right ctrl key (that is, `ctrlL` or `ctrlR`). | ||
> `shift` also indicates either shift key. The left and right shift keys are not distinguishable in this specification. | ||
> | ||
> If there is a layer with a modifier `alt`, there may not be another layer with `altL` or `altR`. Similarly, if there is a layer with a modifier `ctrl`, there may not be a layer with `ctrlL` or `ctrlR`. | ||
> | ||
> - `none` (no modifier, may not be combined with others) | ||
> - `alt` | ||
> - `altL` | ||
> - `altR` | ||
> - `caps` | ||
> - `ctrl` | ||
> - `ctrlL` | ||
> - `ctrlR` | ||
> - `shift` | ||
> | ||
> Note that `alt` in this specification is referred to on some platforms as "opt" or "option". | ||
> | ||
> Left- and right- side modifiers (such as `"altL ctrlR"` or `"altL altR"`) should not be used together in a single `modifier` attribute value. | ||
> | ||
> For hardware layouts, the use of `@modifier` as an identifier for a layer is sufficient since it is always unique among the set of `layer` elements in a keyboard. | ||
> For hardware layouts, the use of `@modifiers` as an identifier for a layer is sufficient since it is always unique among the set of `layer` elements in each `form`. | ||
> | ||
> The set of modifiers must match `(none|([A-Za-z0-9]+)( [A-Za-z0-9]+)*)` | ||
> | ||
> To share a layer between two modifier sets, the layer data must be duplicated. | ||
> To indicate that no modifiers apply, the reserved name of `none` is used. | ||
|
||
**Syntax** | ||
|
||
```xml | ||
<layer id="base" modifiers="none"> | ||
<row keys="a" /> | ||
</layer> | ||
|
||
<layer id="upper" modifiers="shift"> | ||
<row keys="A" /> | ||
</layer> | ||
|
||
<layer id="altgr" modifiers="altR"> | ||
<row keys="a-umlaut" /> | ||
</layer> | ||
|
||
<layer id="upper-altgr" modifiers="altR shift"> | ||
<row keys="A-umlaut" /> | ||
</layer> | ||
``` | ||
|
||
#### Layer Modifier Components | ||
|
||
The following modifier components can be used, separated by spaces. | ||
|
||
- `none` (no modifier) | ||
- `alt` | ||
- `altL` | ||
- `altR` | ||
- `caps` | ||
- `ctrl` | ||
- `ctrlL` | ||
- `ctrlR` | ||
- `shift` | ||
- `other` (matches if no other layers match) | ||
|
||
1. `alt` in this specification is referred to on some platforms as "opt" or "option". | ||
|
||
2. `none` and `other` may not be combined with any other components. | ||
|
||
#### Modifier Left- and Right- keys | ||
|
||
1. `L` or `R` indicates a left- or right- side modifier only (such as `altL`) | ||
whereas `alt` indicates _either_ left or right alt key (that is, `altL` or `altR`). `ctrl` indicates either left or right ctrl key (that is, `ctrlL` or `ctrlR`). | ||
|
||
2. If there are any layers (in the same `form=`) with a modifier `alt`, there may not also be another layer with `altL` or `altR`. Similarly, if there is a layer with a modifier `ctrl`, there may not be a layer with `ctrlL` or `ctrlR`. | ||
|
||
3. Left- and right- side modifiers may not be mixed together in a single `modifier` attribute value, so neither `altL ctrlR"` nor `altL altR` are allowed. | ||
|
||
4. `shift` indicates either shift key. The left and right shift keys are not distinguishable in this specification. | ||
|
||
#### Layer Modifier Matching | ||
|
||
Layers are matched exactly based on the modifier keys which are down. For example: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Problems
The other issues are more serious. I do not think this PR approaches a solution to the problems raised earlier. Without a solution, I don't think we can advance beyond tech preview.
There are various options to solve these. 1.1 No match 1.2 Multiple matches
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @macchiati the current PR allows multiple modifier sets, so would not require as much repetition.
These can be helpful for comparison, but it should be noted that it's not a goal to be able to capture or support all actual keyboards. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that it is not the goal to support all existing keyboards, but also that it would help adoption if vendors could switch to the LDML for their data. That said, Windows only needs repeated layers to cover altR = ctrl+alt cases. Does @macchiati have any specific example in mind which would need lots of repetition? |
||
|
||
- `none` as a modifier will only match if *all* of the keys `caps`, `alt`, `ctrl` and `shift` are up. | ||
|
||
- `alt` as a modifier will only match if either `alt` is down, *and* `caps`, `ctrl`, and `shift` are up. | ||
|
||
- `altL ctrl` as a modifier will only match if the left `alt` is down, either `ctrl` is down, *and* `shift` and `caps` are up. | ||
|
||
- `other` as a modifier will match if no other layers match. | ||
|
||
Multiple modifier sets may be separated by commas. For example, `none, shift caps` will match either no modifiers *or* shift and caps. `ctrlL altL, altR` will match either left-control and left-alt, *or* right-alt. | ||
|
||
Keystrokes where there isn’t an explicitly matching layer, and where there is no layer with `other` specified, are ignored. | ||
|
||
* * * | ||
|
||
### <a name="Element_row" href="#Element_row">Element: row</a> | ||
|
||
A `row` element describes the keys that are present in the row of a keyboard. | ||
|
||
|
||
|
||
**Syntax** | ||
|
||
```xml | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks arbitrary, why? If implementation cannot distinguish left and right keys that's one thing, but why does the specification need such limitation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I lost my comment here, but basically, is this needed in real keyboards we expect to be developed? It can be done later very easily if there's a solid use case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It sounds like it increases complexity to mandate this, but we can lift this later of course.
(Canadian Multilingual Standard on Windows has an extra shift state mapped to ctrlR. It also has ctrl+alt layer and altR=ctrl+alt, which technically in this case means altR=ctrlL+alt. So technically, this one could define ctrlL+ctrlR or altL+ctrlR, but it currently does not, so the answer to your question is no, I am not currently aware of existing keyboard that would require this.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my end, I think this was just a usability thing. No technical reason I am aware of (AFAIK, hardware keyboards don't struggle with those L/R modifier chording pairs).