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

Delete block shortcut: update to be more intuitive and farther from "undo" #68139

Closed
jasmussen opened this issue Dec 19, 2024 · 17 comments · Fixed by #68164
Closed

Delete block shortcut: update to be more intuitive and farther from "undo" #68139

jasmussen opened this issue Dec 19, 2024 · 17 comments · Fixed by #68164
Assignees
Labels
[Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... [Status] In Progress Tracking issues with work in progress

Comments

@jasmussen
Copy link
Contributor

When you select an image, you can press Delete or Backspace to delete it. This is intuitive enough.

When you select a paragraph, those keys delete characters, as you would in any text editor. But if you want to delete the entire paragraph, the current default shortcut is ControlOptionZ on Mac, or ControlAltZ on Windows.

This shortcut is both far from the backspace/delete keys that usually are related to removing, it's also very close to the undo command, CommandZ. It may be confusing to have a destructive action share the same keycode as undo.

Beyond allowing users to customize keyboard shortcuts, which would be highly valuable regardless (#3218), is there a keyboard shortcut that is more intuitive (closer to Backspace and Delete keys), farther from undo, and doet not conflict with other assigned shortcuts?

Can that shortcut be:

  • Mac: Command + Shift + Delete
  • Windows: Control + Shift + Delete

Conceptually the two modifier keys help indicate: this is a forceful action, and the dual nature of backspace and delete both working for this action would match the behavior for non-text blocks.

Related: #51356

@jasmussen jasmussen added the [Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... label Dec 19, 2024
@jarekmorawski
Copy link
Contributor

Sounds good to me! I immediately thought of the Shift + Delete combination before I even finished reading your description. Can we drop Command/Control? The shortcut would then work similarly to Shift + Enter in Figma that immediately zooms out and selects the parent of the currently edited object.

@jasmussen
Copy link
Contributor Author

The simpler the better, the main reason I avoided "Shift+Delete" is because on Windows in older iterations, Shift + Delete would map to "Cut". It's my impression this is very rarely used today, so it might be okay, but that was the motivation for the larger set, at least.

@yogeshbhutkar
Copy link
Contributor

I believe the Shift+Delete combination is a solid approach to proceed with. I'll be linking a PR for the patch shortly.

@Mamaduka
Copy link
Member

@t-hamano is a Windows shortcuts wizard (🧙); let's see what he thinks about the proposal.

Personally, the current shortcut never made sense to me; even using the Delete or D key as the last part of the combo would be preferable.

Let's ensure we're not overriding any obvious OS or browser shortcut with a new combo.

@t-hamano
Copy link
Contributor

On Windows, the shortcut is Shift+Alt+Z. I have never used the current keyboard shortcuts because the three keys are so close together that they are difficult to press 😅

the main reason I avoided "Shift+Delete" is because on Windows in older iterations, Shift + Delete would map to "Cut".

Unfortunately, in my environment, this shortcut still works as "cut":

5d5d469a36d154bb804d6e7179d47758.mp4

It would be better if we could check shortcut conflicts not only on Windows OS and Mac, but also on Linux OS.

By the way, I looked into the history of this shortcut and found that initially Ctrl+Alt+Backspace (Alt+Cmd+Backspace) was used (#8805). It seems that it was later changed to the current shortcut key (#10008).

@yogeshbhutkar
Copy link
Contributor

the main reason I avoided "Shift+Delete" is because on Windows in older iterations, Shift + Delete would map to "Cut".

Unfortunately, in my environment, this shortcut still works as "cut":

Maybe then, as per the suggestion provided by @Mamaduka, we can try out Shift + d instead of Shift + delete, if it doesn't overlap with any other pre-existent shortcuts.

@t-hamano
Copy link
Contributor

t-hamano commented Dec 21, 2024

shift+d is needed to type capital D. Below are all the possible shortcuts in Windows:

Key Action
ctrl+d ⚠️ Chrome and Firefox shortcut (bookmark current page)
shift+d ❌ Type a capital D
alt+d ⚠️ Chrome and Firefox shortcut (Focus the address bar)
ctrl+shift+d ❌ Block Editor shortcut (Duplicate the selected block)
ctrl+alt+d ✅ Avairable
shift+alt+d ❌ Block Editor shortcut (Strikethrough the selected text.)
ctrl+shift+alt+d ✅ Avairable
Key Action
ctrl+del ⚠️ OS shortcut (Delete words to the right)
shift+del ⚠️ Chrome shortcut (Cut)
alt+del ✅ Avairable
ctrl+shift+del ⚠️ Chrome and Firefox shortcut (Delete browsing data)
ctrl+alt+del ⚠️ OS shortcut (Launch Task Manager)
shift+alt+del ✅ Avairable
ctrl+shift+alt+del ✅ Avairable
Key Action
ctrl+backspace ⚠️ Deletes the word to the left of the cursor
shift+backspace ✅ Avairable
alt+backspace ⚠️ OS shortcut (Undo)
ctrl+shift+backspace ✅ Avairable
ctrl+alt+backspace ✅ Avairable
shift+alt+backspace ✅ Avairable
ctrl+shift+alt+backspace ✅ Avairable

Personally, I find the del key more intuitive than the d key given its role. Also, it would be nice to be able to use the same key combinations across both operating systems.

In that sense, ctrl+shift+del seems the most natural choice to me, but this shortcut is for deleting browsing data. Since there are probably no users who frequently delete browsing data, I think it would be fine to overwrite this shortcut, but what do you think?

@yogeshbhutkar
Copy link
Contributor

ctrl+shift+del seems the most natural choice to me

This sounds good to me. I will be updating the PR to incorporate the changes discussed here. Thanks for the suggestions 🚀.

@talldan
Copy link
Contributor

talldan commented Dec 23, 2024

Ctrl + Shift + Del is used to clear browsing data on my browser:
Image

edit: sorry, just saw that was mentioned. Overriding it might be ok.

@talldan
Copy link
Contributor

talldan commented Dec 23, 2024

I think there's actually a lot of confusion in this issue. Most Macs don't have a delete key (unless you're using an external keyboard that has one), they have a backspace key that's labelled 'delete' but isn't delete.

I think what's being proposed is actually Cmd + Shift + Backspace on a Mac.

The Windows shortcut would then be Ctrl + Shift + Backspace, which when I test it does nothing, but I haven't tested all browsers, only Brave.

I'm not sure what Windows laptops do, haven't had one for a number of years, but similar might apply, it's really backspace that we're discussing. 😄

@talldan
Copy link
Contributor

talldan commented Dec 23, 2024

I'm wondering if Ctrl + Backspace on a mac, Alt + Backspace on windows might be an even simpler combo.

@yogeshbhutkar
Copy link
Contributor

yogeshbhutkar commented Dec 23, 2024

I'm wondering if Ctrl + Backspace on a mac, Alt + Backspace on windows might be an even simpler combo.

I think I agree with @talldan here.

CTRL + Backspace on Mac is a good way forward as it's simpler than the previous proposed approach. We can't use CMD here because CMD + Backspace is used to delete the content all the way to the back, which might quite frequently be used.

Edit: Also, for people using 60% keyboards, we don't have delete keys as such, we need to use Fn to hit delete which makes delete even more inconvenient for us. (The previous combo for us would then become CMD + SHIFT + FN + DELETE) Although, I agree that it might just be a small group of people 🙂.

@jasmussen
Copy link
Contributor Author

Coming back to this, thanks for excellent discussion:

I'm wondering if Ctrl + Backspace on a mac, Alt + Backspace on windows might be an even simpler combo.

Reading up on the notes I had for this, I think I actually meant to suggest in the initial issue that both backspace and delete functions should work, just with added modifiers before both of them. I don't know where that aspect of my notes disappeared, but that's also secondary since there are a lot of good suggestions here, all of which seem to improve things.

We could go with the above quoted suggestion, though I also like Aki's suggestion here:

In that sense, ctrl+shift+del seems the most natural choice to me, but this shortcut is for deleting browsing data. Since there are probably no users who frequently delete browsing data, I think it would be fine to overwrite this shortcut, but what do you think?

I personally think it's a non-issue to override the "delete browsing data" shortcut, this is already overridden on many tabs, e.g. Google Docs when you have focus in the canvas. (In fact most editors I tried, override this shortcut when focus is in the canvas.)

Macs have a control key too, though commonly command is the counterpart for Windows vs. Mac (e.g. on Windows, it's Ctrl C for copy, on Mac it's ⌘C). So what would feel the most intuitive?

But @yogeshbhutkar (and thank you for contributing with the PR) has a good point about using the Fn key on macbooks vs. extended keyboards, this is a solid argument for the Backspace key.

Ctrl + backspace and alt backspace is a very clean and simple set of shortcuts, seems almost too simple. But it does diverge a bit between the two platforms, could it be the same?

For that reason, I'm a bit drawn to the idea of:

  • ⌘ + Shift + Backspace on Mac
  • Ctrl + Shift + Backspace on Windows

I'd love a stretch goal of having those two be the default shortcuts, but also having ⌘ + Shift + Delete and Ctrl + Shift + Delete work in addition to those. But if we had to choose only one, for the reasons suggested, Backspace may be the better one.

@yogeshbhutkar
Copy link
Contributor

I've updated the PR to incorporate both the Backspace and Delete variants as outlined in the comment by @jasmussen. Additionally, I've resolved the test case issues. The PR is now ready for review.

Image

@jasmussen
Copy link
Contributor Author

Nice. Took the latest for a spin, it's working well for me, but I'd encourage others to chime in.

@t-hamano
Copy link
Contributor

I updated this table to include a combination using the backspace key.

On Windows OS, ctrl+backspace and alt+backspace are used as OS shortcuts.

So, I think shift+backspace OR ctrl+shift+backspace is good for both OS.

For now, I personally don't want to increase the number of block deletion shortcut options too much. Therefore, I prefer to add only one of the shortcuts.

@t-hamano
Copy link
Contributor

Another thing I noticed is that in Linux OS, the ctrl+alt+backspace key seems to be used to kill all programs and go back to the login screen (Source).

So, when a user wants to press ctrl+shift+backspace to delete a block, they may accidentally press ctrl+alt+backspace. So shift+backspace might be better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... [Status] In Progress Tracking issues with work in progress
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants