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

Distraction free mode: Keyboard shortcut not working #47873

Closed
t-hamano opened this issue Feb 8, 2023 · 4 comments · Fixed by #47900
Closed

Distraction free mode: Keyboard shortcut not working #47873

t-hamano opened this issue Feb 8, 2023 · 4 comments · Fixed by #47900
Assignees
Labels
Needs Testing Needs further testing to be confirmed. [Package] Keyboard Shortcuts /packages/keyboard-shortcuts

Comments

@t-hamano
Copy link
Contributor

t-hamano commented Feb 8, 2023

Description

Related to: #41740

Pressing the shortcut key indicated in the options menu does not switch to the distraction-free mode.

Shortcuts to switch to full-screen mode or to the code editor both work correctly. I tested on Windows, but would be happy if someone could test to see if this problem reproduces on a Mac as well.

Step-by-step reproduction instructions

  • Open the editor.
  • Press Ctrl + Shift + \ key (This is a shortcut for Windows) .
  • Nothing happens

Screenshots, screen recording, code snippet

debc0d120fbe639205782314a8d2901c.mp4

Environment info

  • OS: Windows 11
  • Wordpress Version: WordPress 6.2-alpha-55250
  • Gutenberg Version: Version 15.1.0-rc.1

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@t-hamano t-hamano added Needs Testing Needs further testing to be confirmed. [Package] Keyboard Shortcuts /packages/keyboard-shortcuts labels Feb 8, 2023
@skorasaurus
Copy link
Member

I'm able to reproduce in ubuntu 18.04; Gutenberg 15.0.1; WordPress 6.1; nothing happens with the Ctrl + Shift + \ key.

@glendaviesnz
Copy link
Contributor

glendaviesnz commented Feb 8, 2023

On a Mac the shift - command - \ (⇧ ⌘ \ ) works to toggle distraction free mode for me.

@t-hamano
Copy link
Contributor Author

t-hamano commented Feb 9, 2023

Thank you for the test!

I think the problem may be related to the keyboard layout.

I used JavaScript Key Code Event Tool to get a event dump. My Japanese keyboard layout showed the following results.

Just press the \ key:

{
  "key": "\\",
  "keyCode": 226,
  "which": 226,
  "code": "IntlRo",
  "location": 0,
  "altKey": false,
  "ctrlKey": false,
  "metaKey": false,
  "shiftKey": false,
  "repeat": false
}

Hold down ctrl and shift and press \ key:

{
  "key": "_",
  "keyCode": 226,
  "which": 226,
  "code": "IntlRo",
  "location": 0,
  "altKey": false,
  "ctrlKey": true,
  "metaKey": false,
  "shiftKey": true,
  "repeat": false
}

You can confirm that the value of event.key has changed. This may possibly be due to the fact that keyboard events consider modifier keys, as in the fix made in #43428.

On my Japanese keyboard, if I press the shift key and \ at the same time, _ is typed. If I try and change the shortcut character to another character, the distraction free mode toggle works correctly. Perhaps on the Mac, the \ key doesn't have a combination key when the shift key is pressed, so this problem may not be reproducible in some cases.

I will look into this a bit more to see what approach would be appropriate.

@t-hamano
Copy link
Contributor Author

t-hamano commented Feb 9, 2023

Okay, perhaps the problem could be that the shift key has a character variation when it is pressed.
The complication is that the variations are not matched by the keyboard layout.

Here is what I have found out (on Windows):

Key Pressed with the shift key
on Japanese keyboard layout
Pressed with the shift key
on Japanese keyboard layout
, < <
. > >
/ ? ?
\ (top position) ` `
\ (bottom position) _ N/A
; + :
: * N/A
] } }
@ ` N/A
[ { {
1 ! !
2 " @
3 # #
4 $ $
5 % %
6 & ^
7 ' &
8 ( *
9 ) (
0 N/A )
- = _
^ ~ N/A
= N/A +

Windows Japanese Keyboard Layout

jp

Windows English Keyboard Layout

en

@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Feb 9, 2023
@priethor priethor removed the [Status] In Progress Tracking issues with work in progress label May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Testing Needs further testing to be confirmed. [Package] Keyboard Shortcuts /packages/keyboard-shortcuts
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

4 participants