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

Make keyboard layouts in charge of modifier keys and formatting of keys #257

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

Commits on Oct 31, 2021

  1. Revert "Add arrow glyphs jupyterlab#151"

    This reverts commit 57a6ee7.
    
    It was not clear in issue jupyterlab#151 calling for a change in formatting of arrows that arrows should not be treated as modifier keys.
    jasongrout committed Oct 31, 2021
    Configuration menu
    Copy the full SHA
    c093829 View commit details
    Browse the repository at this point in the history

Commits on Nov 2, 2021

  1. Format a key for display in the keyboard layout.

    This puts the formatting of human-readable strings closer to where the keys are actually defined, and allows new keyboard layouts to extend this formatting for other keys the keyboard may have.
    
    This is exploratory work. It seems that the formatting of specific keys is not standardized across applications, operating systems, or keyboards, so I’m not sure if this will make anyone happier. It does seem like the keyboard layout is the right place for this formatting logic to happen for individual keys in the layout.
    
    I did verify that VoiceOver reads each of the macOS shortcuts correctly in menus (e.g., the curvy right arrow is read as “return” in a menu, etc.)
    jasongrout committed Nov 2, 2021
    Configuration menu
    Copy the full SHA
    0371ee5 View commit details
    Browse the repository at this point in the history
  2. More work on using modifier keys from the layout instead of hardcodin…

    …g them.
    
    This adds a modifierKeys attribute to the keyboard layout so we can iterate over the modifier keys. Since we often want to our modifier keys displayed in a specific order, we need the modifier keys to be an ordered set, but Object.keys ordering is not guaranteed until ES2020, I believe. Therefore I converted the modifier keys to a Set, which does iterate in insertion order for sure.
    
    Finally, we make a kind of awkward special case for Command/Meta treatment on macos so that things are backwards-compatible with the current behavior.
    
    There are some blockers to further progress using getModifierState to determine modifier keys:
    
    1. It does not appear that we can easily clone a KeyboardEvent and clone the getModifierState function, at least not as easily as we did for the standardized ctrl, shift, alt, etc. A way forward is that we could keep a reference to the original event and proxy getModifierState calls to the original event.
    2. The current keyboard layout specifies the control key as “Ctrl”, not the standardized “Control” used in getModifierState. This is so that users can specify their keyboard shortcuts using “Ctrl” instead of “Control”. To make more progress here, we could use “Control” in the keyboard layout, and carefully trace where “Ctrl” was used and convert it to “Control” at the appropriate places.
    jasongrout committed Nov 2, 2021
    Configuration menu
    Copy the full SHA
    5521525 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    03db23e View commit details
    Browse the repository at this point in the history
  4. Change the Control modifier in the keyboard layout from Ctrl to Control.

    We still keep the user-facing label as Ctrl for now for compatibility.
    
    This may be considered a breaking change in the keyboard package, since the layout has been changed to reference ‘Control’.
    jasongrout committed Nov 2, 2021
    Configuration menu
    Copy the full SHA
    bfdf926 View commit details
    Browse the repository at this point in the history
  5. Revert "Change the Control modifier in the keyboard layout from Ctrl …

    …to Control."
    
    This reverts commit bfdf926.
    jasongrout committed Nov 2, 2021
    Configuration menu
    Copy the full SHA
    f59ced4 View commit details
    Browse the repository at this point in the history
  6. Convert Ctrl to Control when checking the modifier state.

    This preserves backwards compatibility for the keyboard layout, while still switching to getModifierState for checking the modifier state.
    jasongrout committed Nov 2, 2021
    Configuration menu
    Copy the full SHA
    a8bf225 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    d15b22e View commit details
    Browse the repository at this point in the history
  8. Fix shortcut formatting.

    jasongrout committed Nov 2, 2021
    Configuration menu
    Copy the full SHA
    be5d3ff View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    4acd80e View commit details
    Browse the repository at this point in the history
  10. Delete debugging output

    jasongrout committed Nov 2, 2021
    Configuration menu
    Copy the full SHA
    34c3d92 View commit details
    Browse the repository at this point in the history