processing / p5.js-web-editor

The p5.js Editor is a website for creating p5.js sketches, with a focus on making coding accessible and inclusive for artists, designers, educators, beginners, and anyone else! You can create, share, or remix p5.js sketches without needing to download or configure anything.
https://editor.p5js.org
GNU Lesser General Public License v2.1
1.37k stars 1.32k forks source link

Adding keyboard shortcut for delete a file. #3018

Closed Swarnendu0123 closed 4 months ago

Swarnendu0123 commented 7 months ago

Increasing Access

Screenshot (76) If we select the file and click on delete button on keyboard, at this point of time the file is not getting deleted.

Feature enhancement details

We can add a shortcut, select that file and press the delete key on keyboard, and editor will ask for the confirmation via alert() and on confirmation we can delete the file.

Screenshot (78) also we can update the shortcut instruction.

lindapaiste commented 7 months ago

I'm not opposed but let's think this through.

The current behavior:

also we can update the shortcut instruction.

I wouldn't put it there because those are global shortcuts, but this is only if the file is selected.

praveen-rikhari commented 7 months ago

@Swarnendu0123 @lindapaiste any update on this or should i start working on this?

Swarnendu0123 commented 7 months ago

Well @praveen-rikhari,

When the focus is in the editor, pressing Delete removes the next character in front of the cursor (vs. Backspace, which removes the character behind the cursor. When the focus is on the filename in the sidebar, pressing Delete does not do anything. If I click somewhere in the sidebar, I can delete the currently-opened file through keyboard controls by Tabbing to the dropdown menu for that file and selecting the "Delete" item

We have already figured out this part.

If I want to delete a file which is not currently open that's lot bit trickier. I Tab to that file name and hit Enter -- this opens the file and moves the focus to the text of the file in the editor. Which is good, but once the focus is in the editor I cannot figure out how to get the focus out of the editor using the keyboard alone. I have to click in the sidebar and then use the previous steps.

But, in this part I feel we need a clear approach. Can you please share, how you are going to implement that, maybe we could come up with a better solution. Though, I have one approach for this: https://youtu.be/3ucnmBSp1xQ?si=whXQURv2e4uva46J

praveen-rikhari commented 7 months ago

@Swarnendu0123 Yes, I have come up with an idea which looks like this :

Swarnendu0123 commented 7 months ago

Yes @praveen-rikhari! I have also came up with a similar solution, and already created the PR.

praveen-rikhari commented 7 months ago

Awesome @Swarnendu0123 thanks i will take a look at the code

raclim commented 4 months ago

Thanks for raising this! I'm a bit hesitant about adding too many keyboard shortcuts to the list, and feel that this might not be needed for now. However, I'm down to implement this in the future if this gets more traction or gets further attention down the line!