Open Bug 1627590 Opened 5 years ago Updated 3 years ago

KeyboardEvent.key holds the wrong value for Command-Shift-modified printable keys

Categories

(Core :: DOM: Events, enhancement, P5)

x86_64
macOS
enhancement

Tracking

()

People

(Reporter: marijnh, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

When Shift and Command are held and a printable key that produces a different character with Shift than without Shift is pressed, the keydown event's "key" property will, on macOS, hold the non-shifted variant. This problem does not exist with Control.

The spec is slightly vague on this, but this tweet from one of its authors indicates that the intent is for the shifted character to be provided in this case: https://twitter.com/garykac/status/1212759678024740864

Chrome and Safari have the same issue. See https://bugs.webkit.org/show_bug.cgi?id=174782

Hi! I will set Product and Component to have a starting point for this.
DOM: Events team, if this is not the right component please feel free to route this ticket to the corresponding team, thanks!

Component: Untriaged → DOM: Events
Product: Firefox → Core
Attached file test2.html

By attachment 9141288 [details], I can see the symptom on Mac
The key is "L" when pressing "shift" and "shift+ctrl" with "l".
But the key is "l" when pressing "shift + command" with l.

  1. keydown charCode=0 key=L character=|| modifiers=Shift

  2. keyup charCode=0 key=L character=|| modifiers=Shift

  3. keydown charCode=0 key=L character=|| modifiers=Ctrl+Shift

  4. keyup charCode=0 key=L character=|| modifiers=Ctrl+Shift

  5. keydown charCode=0 key=Meta character=|| modifiers=Meta

  6. keydown charCode=0 key=l character=|| modifiers=Shift+Meta ----> key is 'l'

  7. keydown charCode=0 key=l character=|| modifiers=Shift+Meta

  8. keyup charCode=0 key=Meta character=||

This symptom doesn't happen on Win 10.

Hello masayuk,
Could you have some comments about this?

(On Win 10)

  1. keydown charCode=0 key=L character=|| modifiers=Shift

  2. keyup charCode=0 key=L character=|| modifiers=Shift

  3. keydown charCode=0 key=L character=|| modifiers=Ctrl+Shift

  4. keyup charCode=0 key=L character=|| modifiers=Ctrl+Shift

  5. keydown charCode=0 key=OS character=||

  6. keyup charCode=0 key=L character=|| modifiers=Shift -------> key is 'L'

Flags: needinfo?(masayuki)
Priority: -- → P3

This is currently intentional. If OS provides "modified" character for the key, we use it as-is. And macOS sends unshifted character to apps when Command key is pressed. From web-compart point of view, we cannot change our behavior until Blink changes their behavior. As I said in the spec issue, we need to take care of complicated cases if Command switches layout temporarily like Dvorak-QWERTY command keyboard layout.

Type: defect → enhancement
Flags: needinfo?(masayuki)
Priority: P3 → P5
OS: Unspecified → macOS
Hardware: Unspecified → x86_64
Version: unspecified → Trunk
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: