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.32k stars 1.27k forks source link

Add a keyboard shortcut for adding a new file #1292

Open nik72619c opened 4 years ago

nik72619c commented 4 years ago

Nature of issue?

Details about the bug:

catarak commented 4 years ago

I'm wary of adding too many keyboard shortcuts. Especially since this tool is used in a lot of beginner teaching contexts, and lots of keyboard shortcuts can be kind of overwhelming/make the tool feel advanced. Open to discussion about what feel like important keyboard shortcuts!

shakti97 commented 4 years ago

yes in the beginning they might feel this, but as soon as they start spending time they would really love these shortcuts, and in the long run these shortcut will help them alot.

catarak commented 4 years ago

I hear you! I definitely see the benefit. I feel like this actually related to #765—it would be rad to combine the New File/Folder modals, and allow users to create nested files! I think that issue may actually need to be tackled first.

Would the keyboard shortcut be Cmd/Ctrl+N?

neelesh7singh commented 3 years ago

I would like to work on this issue if no one is working on it.

I hear you! I definitely see the benefit. I feel like this actually related to #765—it would be rad to combine the New File/Folder modals, and allow users to create nested files! I think that issue may actually need to be tackled first.

Would the keyboard shortcut be Cmd/Ctrl+N?

I don't think we can override Ctrl + N on chrome

catarak commented 3 years ago

I don't think we can override Ctrl + N on chrome

I tried testing this on CodeSandbox, which says that it has the keyboard shortcut cmd/ctrl + N for a new file. When you try this shortcut, on Chrome and Firefox, it just opens a new browser window.

You are welcome to work on this! I'd first take some time and think about what a good shortcut would be.

neelesh7singh commented 3 years ago

Should I make a pr and change the shortcut there or wait before making a pr??

catarak commented 3 years ago

Should I make a pr and change the shortcut there or wait before making a pr??

Feel free to open a PR!

catarak commented 3 years ago

I'm coming back to this issue in the midst of cleaning out stale issues. I do like having a keyboard shortcut for this, but I'm really stumped as to what it should be! Command/Control + N is the standard for desktop text editors, and in the browser, it's the standard for opening a new browser window.

m2a9x45 commented 1 year ago

Hi 👋 I've started looking into this, currently I've gone for Command / Shift + N as the shortcut to create new file as it looks like control isn't possible from the discussion.

Just to let you know this is my first open source contribution, so if I've done anything wrong please do let me know. Thanks.

https://github.com/processing/p5.js-web-editor/pull/2213

lindapaiste commented 10 months ago

I'm coming back to this issue in the midst of cleaning out stale issues. I do like having a keyboard shortcut for this, but I'm really stumped as to what it should be! Command/Control + N is the standard for desktop text editors, and in the browser, it's the standard for opening a new browser window.

The editor already overrides some commands which are built in to the browser. For example Ctrl-F (for our custom "find" instead of the browser's find text) and Ctrl-H (for "replace text" instead of opening history). So it seems like it should be possible to use Ctrl-N if we call e.preventDefault() in the handler. Would we want this? Or is it too confusing?

sdivyanshu90 commented 10 months ago

No, we can't override Ctrl-N even by using e.preventDefault() in the handler. In Chrome, Ctrl-N is the default shortcut for opening a new tab, and it cannot be overridden. For more information, you can refer to this Stack Overflow thread: link to the Stack Overflow discussion.