Override Default ENTER key behavior?

Sometimes when I am selecting multiple files using the shift key I will accidentally hit the ENTER key right above it. This can result in hundreds of files being launched, grinding my system to a halt until all resources run out.

I want to be able to override the default ENTER key behavior so that it does not do this, or at the very least pops a dialog asking my confirmation for opening multiple files. I see an option in power mode that does this, but I use details mode, not power mode, otherwise the Shift/Enter key juxtaposition wouldnt be a problem. But power mode isn't for me.

How would I do this in the Customize->Keys->Advanced section?

TIA.

Go to Customize / Keys and add a New hotkey. Turn off the System-wide Hotkey option and set the hotkey to Enter. Leave the function blank and set the name to whatever you want.

After doing that, pressing Enter in a lister won't do anything anymore.

I want it to work for a single file... not multiple files. How would I do that.

It is not obvious how to check how many files are selected using the sciprting language, or how to do a default execute.

So my question is specifically: I want ENTER to work when I press it with one file selected. I do not want it to work when I have some arbitrary number of files > 1 selected.

Ie.

If (number_of_files < X) then
open files

Even if I could change it so it would only open one of the files (presumably using the {file} command code). However simply setting the ENTER key to {file} still opens all of the selected files, not just one, though it does give the nifty custom file command progress bar when opening them.

At the moment, without running everything through an external program or script*, there isn't a way to do different things depending on how many files are selected.

There might be a way to make it only run the first file when you hit enter. (I can't find it right now but I seem to remember a way to make a command only run on the first selected item. Can anyone else think of this or am I imagining it?)

(*If you know VBScript or Perl or whatever then you could send all the filenames to a script that then launches them depending on the number of filenames it was given.)

How about:

@firstfileonly
dopusrt /cmd FileType FILE {file} ACTION=open
@nodeselect

I think that was the directive Nudel was thinking about.

Awesome. That did the trick. Not obvious and not ideal lol, but it works.

Actually this works too:

@firstfileonly
{file}
@nodeselect

Not sure if there is any benefit to one of the other tho.

Thanks again.

[quote="steje"]How about:

@firstfileonly
dopusrt /cmd FileType FILE {file} ACTION=open
@nodeselect

I think that was the directive Nudel was thinking about.[/quote]
Nudel, Steje, or anyone else who knows any of these directives

The documentation seems to be anorexic on a list of directives than can be used in buttons or key assignments. Can we get a sticky on this forum with all of them? Perhaps start a thread where people could post or see examples of using them?

I've added a FAQ about them:

resource.dopus.com/viewtopic.php?p=8513#8513

Thanks Jon!