-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Distraction free mode: Fix keyboard shortcut not working #47900
Conversation
Size Change: +23 B (0%) Total Size: 1.33 MB
ℹ️ View Unchanged
|
fd78509
to
2ba70ae
Compare
const replacementWithShiftKeyMap = { | ||
Comma: ',', | ||
Backslash: '\\', | ||
// Windows returns `\` for both IntlRo and IntlYen. |
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 comment was taken from the source code of chromium
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.
@t-hamano Works fine for me.
Thank you for the review, @alexstine! I will wait for someone to test it on Mac (because I don't have Mac...). |
@t-hamano I have Mac as well, what is the keyboard shortcut? Spell it out if you do not mind, I cannot figure out what the icons mean in the PR description. |
Thank you for the test, @alexstine. The shortcut on the Mac would be ‘shift‘ + |
@t-hamano Yes, this issue does occur on Mac for trunk. It also is not impacted by your PR. Pressing cmd+shift+\ results in opening the new tabs in Safari. Seems like event is not prevented or the shortcut is not getting interpreted correctly. |
Thanks for the test, @alexstine! I have removed Shortcut key is |
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.
Shortcut key is shift + command + , (Comma). It would be great if you could also test if this shortcut works as well on Macs as it has in the past 🙏
Tested and works before. Thanks @t-hamano !
* Distraction free mode: Fix keyboard shortcut not working on Windows * Include mac
Cherry-picked this PR to the wp/6.2 branch. |
Fixes: #47873
Related to: #43428
What?
This PR fixes a problem where the shortcut for switching distraction flow mode did not work (probably Windows only).
Why?
The shortcut for switching the distraction free mode is as follows:
Ctrl
+Shift
+\
⇧
+⌘
+\
The
event.key
for determining shortcuts has a value that takes into account modifier keys such as theshift
key. Therefore, as I have investigated in this comment, I believe the cause is that when theshift
key is combined with other keys,event.key
has a value that is not originally expected. Furthermore, the character changed by theshift
key depends on the keyboard layout, soevent.key
cannot be used as the source of the decision.How?
Refers to the value of
event.code
that represents a physical key on the keyboard. Based on that value, it is converted to the originally expectedevent.key
.This PR fixes the bug in Windows. However, as mentioned in the two comments from here, the test results seem to be different for Mac. I would appreciate it if you could test to see if this shortcut issue is currently occurring on Mac.
Testing Instructions for Keyboard
Screenshots or screencast
English Keyboard Layout
event.code
isBackslash
.en_keyboard.mp4
Japanese Keyboard Layout
event.code
isIntlRo
orIntlYen
.jp_keyboard.mp4