lukehaas / RunJS

RunJS is a JavaScript playground for macOS, Windows and Linux. Write code with instant feedback and access to Node.js and browser APIs.
https://runjs.app
2k stars 43 forks source link

Run code from keyboard #606

Closed jurajkapsz closed 4 months ago

jurajkapsz commented 4 months ago

A feature request or a regression:

I have the Auto-Run option disabled, but now I can only mouse-click the Run button to run the code. This is quite unwieldy when working with/testing code.

I believe in earlier RunJS releases I could press CTRL+ENTER to run the code on demand (haven't tested this, but I've worked regularly in RunJS and something like muscle memory gives me though times with this).

Is there a way to run the code on demand from keyboard?

Using RunJS v2.10.1 @ GNU/Linux

lukehaas commented 4 months ago

The run shortcut is CTRL+R. CTRL+ENTER is a standard editor shortcut for creating a new line under the currently active line.

If you're ever uncertain about a shortcut for a menu item, the shortcut is displayed to the right of items in the menu: Screenshot 2024-02-18 at 11 50 55

Also, a complete list of shortcuts can be found in the docs: https://runjs.app/docs#shortcuts

jurajkapsz commented 4 months ago

If you're ever uncertain about a shortcut for a menu item, the shortcut is displayed to the right of items in the menu:

Ah, right, sorry, big oversight on my side, these keyboard hints are basically in every desktop app out there. For whatever reason, I was looking through the settings options.

Also, a complete list of shortcuts can be found in the docs: https://runjs.app/docs#shortcuts

Thanks very much.

CTRL+ENTER is a standard editor shortcut for creating a new line under the currently active line.

Right, but I was sure I pressed some other combo than CTRL+R as I've used it all the time during coding to apply code formatting (I am pretty sure I did not hit CTRL+R this often or at all).

Maybe it was a while since then. I'll get back to this if I should found out how it was. I'll close this issue for now.

Thanks Luke!

lukehaas commented 4 months ago

There was an older version of RunJS where CTRL+ENTER was a shortcut for the run action, in addition to CTRL+R. But it was pointed out to me that CTRL+ENTER is a standard shortcut for creating a new line, so it should not be used for triggering the run action.

jurajkapsz commented 4 months ago

Good old times :)

Would it be possible to reintroduce it somehow? Maybe as ALT+ENTER? I think that this shortcut is free, if I'm not mistaken.

I really often run my code - after writing any code block or expression - to benefit from code formatting, runtime check etc., as I use RunJS for general learning purposes. CTRL+R is a bit harsh on hand to be used this often. ALT+ENTER goes very well in hand (ie left ALT, if there's a difference), basically the same way as CTRL+ENTER did.

I know, that there is the Auto-run option, but that is a different mode for me, I definitely prefer to run my code as I finish some of it, not seeing unexpected token errors on the way etc.

Also, I've noticed now, when enabling the Vim key-bindings, the CTRL+R shortcut does not work anymore. Maybe CTRL+ENTER would be fine for that mode - or ALT+ENTER - to unite the shortcut action, if it could be available at all.

jurajkapsz commented 4 months ago

Also, I've noticed now, when enabling the Vim key-bindings, the CTRL+R shortcut does not work anymore. Maybe CTRL+ENTER would be fine for that mode - or ALT+ENTER - to unite the shortcut action, if it could be available at all.

Nah, it works, but I have to be in the "insert" mode. Hm..

jurajkapsz commented 4 months ago

ALT+ENTER

Hi @lukehaas , I would like to ask, any chance with this approach? Can't think of where is this key combination already being used, I've tried it also in various editors.

lukehaas commented 4 months ago

I'm sorry to say that the ALT+ENTER shortcut is not something I intend to add. I don't see it as a particularly intuitive shortcut for the run command, and I think it's unlikely to be used by many people. It's not clear to me why the current CTRL+R shortcut would be challenging to use or hard to remember. I'm open to reconsidering this if a significant number of people get in touch to say the current CTRL+R is problematic for them but otherwise I think it's best to keep things as they are.

jurajkapsz commented 4 months ago

I'm open to reconsidering this if a significant number of people get in touch to say the current CTRL+R is problematic for them but otherwise I think it's best to keep things as they are.

Just to clarify, I didn't mean to replace the existing CTRL+R (CTRL+R makes also sense as in "R"un), but to add an additional key press combination, ie ALT+ENTER, to execute the code, which is I believe otherwise not being utilized at all (I think across other editors as well). So it would be an alternative to the existing CTRL+R.

It's not clear to me why the current CTRL+R shortcut would be challenging to use or hard to remember.

CTRL+R is totally alright as a shortcut in general but not good enough ergonomically to press actively ie on regular basis (ie as if to add new lines in code, like you can do with CTRL+ENTER).

What I am after is I believe the ergonomic design you decided for by choosing CTRL+ENTER for code execution, which is easy to press whatever number of times and does not cause hand fatique, the keys are larger or more prominent etc. ALT+ENTER works the same if not better imho. I honestly used CTRL+ENTER on daily basis from day one and CTRL+R does not catch up on this.

Maybe this opens up a room for a feature to be able to configure one's own key bindings in preferences, but that is probably a pretty complex feature and otherwise unnecessary, and ALT+ENTER is so unused and specific - also, code execution being a core feature or operation - that it would maybe be alright to only add this one additional key binding?

lukehaas commented 4 months ago

Adding anything to software comes with a cost, even if it's just an additional shortcut. It needs to be maintained throughout the software's lifetime, it needs automated tests which then increase the time it takes to create new releases etc, etc. So anything new that gets added needs to be essential and worth it. Adding something that's likely only going to be used by one person is just not a sustainable way to develop software.

jurajkapsz commented 4 months ago

That's correct.