Using Escape Key as Menu Shortcut Key ?

I have a data entry window with several text fields, check boxes, etc. I also provide a few shortcut keys for things like “Clear All” and “Save All”. Those two items are currently linked to “Alt-C” and “Alt-S” as shortcuts in Windows OS.

A user has requested that I allow the Escape key to also act as a shortcut for “Clear All”. Is there an clean way to do this without capturing every keystroke in every text field and watch for an “Escape” keystroke ?

Thanks in advance.

Ron Bower

You can use “ESC” as a shortcut Key, but it may require a menu modifier.

You can also implement this in a text field subclass and use that subclass on all your windows.

Just enter: Esc

That’s from the docs of MenuItem:

Thanks, Eli - That is exactly the solution I needed. I was pondering Kem’s suggestion for a subclass but realized that the user could hit Escape at times that a text field did not have the focus.