# actionPerformed script doesn't run on enter key

**URL:** <https://forum.inductiveautomation.com/t/actionperformed-script-doesnt-run-on-enter-key/1691>\
**Category:** Archived Topics\
**Created:** [March 26, 2010, 2:05pm UTC](https://forum.inductiveautomation.com/t/actionperformed-script-doesnt-run-on-enter-key/1691 "2010-03-26T14:05:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![krystenoaks](https://avatars.discourse-cdn.com/v4/letter/k/43a26b/32.png) [@krystenoaks](https://forum.inductiveautomation.com/u/krystenoaks)\
**Post date:** [March 26, 2010, 2:05pm UTC](https://forum.inductiveautomation.com/t/actionperformed-script-doesnt-run-on-enter-key/1691/1 "2010-03-26T14:05:44Z")

</div>

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!

Thanks!  
Krysten

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [March 26, 2010, 3:21pm UTC](https://forum.inductiveautomation.com/t/actionperformed-script-doesnt-run-on-enter-key/1691/2 "2010-03-26T15:21:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jim\_lapratt](https://avatars.discourse-cdn.com/v4/letter/j/cc9497/32.png) [@jim\_lapratt](https://forum.inductiveautomation.com/u/jim_lapratt)\
**Post date:** [February 11, 2011, 1:56pm UTC](https://forum.inductiveautomation.com/t/actionperformed-script-doesnt-run-on-enter-key/1691/3 "2011-02-11T13:56:01Z")

</div>

Ok,

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?

Jim

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [March 4, 2011, 9:47pm UTC](https://forum.inductiveautomation.com/t/actionperformed-script-doesnt-run-on-enter-key/1691/4 "2011-03-04T21:47:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jim\_lapratt](https://avatars.discourse-cdn.com/v4/letter/j/cc9497/32.png) [@jim\_lapratt](https://forum.inductiveautomation.com/u/jim_lapratt)\
**Post date:** [March 5, 2011, 4:42pm UTC](https://forum.inductiveautomation.com/t/actionperformed-script-doesnt-run-on-enter-key/1691/5 "2011-03-05T16:42:11Z")

</div>

Thanks Carl.
