Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Some thoughts regarding KeyboardShortcut component

See original GitHub issue

🐛 Bug report

Current behavior

KeyboardShortcut component seems to make multiple assumptions that seem specific to usage in our codebases, to web, to English locale, and more. In particular, it remaps CMD to CTRL on platforms other than macOS.

The problem is that this is not enough to meet platform conventions. On macOS, SHIFT should be first, and only replacing characters without reordering them does not result in display following platform guidelines. CMD + SHIFT + 1 renders as Ctrl Shift 1 on Windows and ⌘ ⇧ 1 on macOS, but it should be ⇧ ⌘ 1 on macOS.

Other potential issues:

  • are we 100% sure that keys are always named “Ctrl” and “Shift” in other locales? I know that some e.g. German locales used “Strg” instead of “Ctrl”

Possible solutions

The component could only do rendering, and leave all other decisions to the caller.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

proxicommented, Nov 2, 2020

it probably should support apps specifying different shortcuts for different platforms Not sure how complex this can get without making the calls to this component not too complex.

I don’t think this is the way to go. Shortcuts could just as well be dynamic (configurable by the user), could change by browser (to avoid clashes) etc. I think it’s much easier to replace shortcuts on client level (e.g. the way we do here by replacing the whole keymap or tweaking some of the constants).

codedebugrepeatcommented, Dec 10, 2020

@proxi I can’t find a similar guideline on the order for Windows, but e.g. look at some official shortcuts here:

A common pattern is for Shift to come second: Ctrl + Shift Alt + Shift

In general, most shortcuts only use 2 modifiers Windows + Alt Windows + Shift Ctrl + Alt etc.

although sometimes, three appear too

Windows logo key  + Ctrl + Shift + B | Wake PC from blank or black screen

Windows key always goes first. So, my not very scientific deduction of order would be, more or less (it’s somewhat flexible):

Windows, Ctrl, Alt, Shift

Read more comments on GitHub >

github_iconTop Results From Across the Web

Everything You Always Wanted to Know about Keyboard ...
To this day, some people live by keyboard shortcuts—on Windows it's Control C for Copy, Control V for paste—and others use the mouse....
Read more >
Keyboard shortcuts in Word - Microsoft Support
Select the first or last cell in the row, and then press Shift+Alt+End or Home. Select the whole table. Alt+5 on the numeric...
Read more >
Understanding Success Criterion 2.1.4: Character Key Shortcuts
A mechanism is available to remap the shortcut to include one or more non-printable keyboard keys (e.g., Ctrl, Alt);; Active only on focus:...
Read more >
Teaching Students About Keyboard Shortcuts | Edutopia
Sometimes we do it without thinking. A quick Ctrl + Z if we want to undo a word we typed. But where did...
Read more >
Keyboard shortcuts - IBM
Action Windows Apple Copy Ctrl+C Command+C Cut Ctrl+X Command+X Paste Ctrl+V Command+V
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found