One option you can play with to fine tune the results on your screen is:
Exit Script [False]
If you use that option, the action from the keystroke is never output to the layout. Thus, you have the option to allow or to not allow the enter key keystroke to put the cursor in the next field in the tab order.
Note that your code locks you into specific field names for your search fields. If you change the name of the name of the field, the script breaks. You may want to pass text in quotes as a script parameter instead. Then you can have expressions in your IF-Else If steps like this:
If [ Get ( ScriptParameter ) = "Course Search"]
Perform Script [ “CM Simple Course Search” ]
Else If [ Get ( ScriptParameter ) = "Author Search" ]
Perform Script [ “CM Simple Author Search” ]
Now you are no longer locked into those field names.
I like the ability to prevent switching to the next field. That was a question I had at one point, and then forgot that I had it. :)
So would the Exit Script [False] just go at the end of the key-checking script?
And thanks for the hint on a script parameter, too. I see what you mean about it breaking if something changes.
Exit script halts the execution of your current script so you'd put it any exit point in your script. Putting it at the very end makes sense for the example you've posted here.
Got it. Works as advertised. Can mess things up if you don't put it INSIDE the IF statement, though. :) (i.e. ALL keystrokes get ignored.)
Yep. Forgot to mention that...