actionPerformed script doesn't run on enter key

According to the User Manual documentation:
To get buttons to do things, you add an Action to the actionPerformed event. … Buttons can also be activated by tabbing over to them and hitting Enter or Space, or they could be activated by pressing Alt and the button’s mnemonic character. …

So I have placed my script on the actionPerformed event; however, when I tab to the button and press either enter key on my keyboard it doesn’t run the script. It does work if I tab to the button and press the space bar. Please let me know what I am missing!


Nope - you’re absolutely correct. The manual is wrong in this case, we’ll modify it.

Even worse - the buttons don’t have key events exposed! This has been changed for Ignition 7.0.6 - where you’ll be able to add a script like this to add enter-to-click logic in the keyPressed event:

if event.keyCode==event.VK_ENTER: event.source.doClick()

Thanks for bringing this to our attention.

1 Like


I am sure I am missing something here… But is there a reason the “Enter” key is not included in the “actionPerformed” routine and we have to enter it manually?


Well, the “reason” is sort of silly, but thats just how Java has defined how buttons work. Space bar = click the focused button, Enter = click the currently focused window’s “default” button (if there is one).

I agree through - not very compelling. We can override this to have enter work for the selected button. For what its worth, many Windows UIs are not consistent on this behavior - the space bar is the norm.

Thanks Carl.