Skip to content
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

Add capability for KeyboardEvent.code + capture #291

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

vidartf
Copy link
Member

@vidartf vidartf commented Feb 3, 2022

This:

  • Adds the capability for KeycodeLayout to also use the code field from KeyboardEvents. It still allows for adding keyCode values to the map, both for backwards compatibility, but also since there are some keys that will not have a code value (it will be either an empty string or "Unidentified").
  • Adds a map for code fields for EN_US.
  • Adds a package with a widget for capturing keyboard layouts.
  • Adds an example app for capturing keyboard layouts.
  • Adds a fallback for mapping the key field from KeyboardEvents onto the list of "Special Keys" from the spec. This is only considered if there are no match for the event via the code/keyCode fields.

Resolves #74.

TODOs:

  • Add tests for capture widget / example.
  • Find a way to explicitly prompt for a key value for "Dead" keys. This might need some extra thought to catch corner cases. We should not try to capture Dead keys, as they are unsuitable for use in shortcuts.
  • Seek out corner cases for layouts where isComposition is relevant. Capture any behavior in tests.
  • Figure out a pattern for adding other layouts. Should they be added to keyboard package, or to one or more separate language packs?

This:
- Adds the capability for KeycodeLayout to also use the `code` field from KeyboardEvents.
- Adds a map for `code` fields for EN_US.
- Adds a package with a widget for capturing keyboard layouts.
- Adds an example app for capturing keyboard layouts.

TODOs:
- Add tests for capture widget / example.
- Figure out a pattern for adding other layouts. Should they be added to keyboard package, or to one or more separate language packs?
@vidartf vidartf added enhancement New feature or request feature Adds functionality labels Feb 4, 2022
@fcollonval
Copy link
Member

Here is what I got using a fr-fr keyboard:

fr-fr layout
codes: {
  "AltLeft": "Alt",
  "AltRight": "AltGraph",
  "ArrowDown": "ArrowDown",
  "ArrowLeft": "ArrowLeft",
  "ArrowRight": "ArrowRight",
  "ArrowUp": "ArrowUp",
  "Backquote": "²",
  "Backslash": "*",
  "Backspace": "Backspace",
  "BracketRight": "$",
  "Comma": ";",
  "ControlLeft": "Control",
  "ControlRight": "Control",
  "Delete": "Delete",
  "Digit0": "À",
  "Digit1": "&",
  "Digit2": "É",
  "Digit3": """,
  "Digit4": "'",
  "Digit5": "(",
  "Digit6": "-",
  "Digit7": "È",
  "Digit8": "_",
  "Digit9": "Ç",
  "End": "End",
  "Enter": "Enter",
  "Equal": "=",
  "Escape": "Escape",
  "F1": "F1",
  "F10": "F10",
  "F11": "F11",
  "F12": "F12",
  "F2": "F2",
  "F3": "F3",
  "F4": "F4",
  "F5": "F5",
  "F6": "F6",
  "F7": "F7",
  "F8": "F8",
  "F9": "F9",
  "Home": "Home",
  "Insert": "Insert",
  "IntlBackslash": "<",
  "KeyA": "Q",
  "KeyB": "B",
  "KeyC": "C",
  "KeyD": "D",
  "KeyE": "E",
  "KeyF": "F",
  "KeyG": "G",
  "KeyH": "H",
  "KeyI": "I",
  "KeyJ": "J",
  "KeyK": "K",
  "KeyL": "L",
  "KeyM": ",",
  "KeyN": "N",
  "KeyO": "O",
  "KeyP": "P",
  "KeyQ": "A",
  "KeyR": "R",
  "KeyS": "S",
  "KeyT": "T",
  "KeyU": "U",
  "KeyV": "V",
  "KeyW": "Z",
  "KeyX": "X",
  "KeyY": "Y",
  "KeyZ": "W",
  "Minus": ")",
  "Numpad0": "0",
  "Numpad1": "1",
  "Numpad2": "2",
  "Numpad3": "3",
  "Numpad4": "4",
  "Numpad5": "5",
  "Numpad6": "6",
  "Numpad7": "7",
  "Numpad8": "8",
  "Numpad9": "9",
  "NumpadAdd": "+",
  "NumpadDecimal": ".",
  "NumpadDivide": "/",
  "NumpadEnter": "Enter",
  "NumpadMultiply": "*",
  "NumpadSubtract": "-",
  "PageDown": "PageDown",
  "PageUp": "PageUp",
  "Period": ":",
  "Quote": "Ù",
  "ScrollLock": "ScrollLock",
  "Semicolon": "M",
  "ShiftLeft": "Shift",
  "ShiftRight": "Shift",
  "Slash": "!",
  "Tab": "Tab"
}

modifiers: ["Alt", "AltGraph", "CapsLock", "Control", "Shift"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature Adds functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Keymap based on .key or .code rather than .keyCode?
2 participants