# ActionPerformed Event on Button when Focused

**URL:** <https://forum.inductiveautomation.com/t/actionperformed-event-on-button-when-focused/104346>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [March 27, 2025, 11:25pm UTC](https://forum.inductiveautomation.com/t/actionperformed-event-on-button-when-focused/104346 "2025-03-27T23:25:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Simon\_Hathout\_Willar](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@Simon\_Hathout\_Willar](https://forum.inductiveautomation.com/u/Simon_Hathout_Willar)\
**Post date:** [March 27, 2025, 11:25pm UTC](https://forum.inductiveautomation.com/t/actionperformed-event-on-button-when-focused/104346/1 "2025-03-27T23:25:43Z")

</div>

Hello.

I am wondering if there is a way to fire the ActionPerformed Event (or any event, really), when the enter key is clicked while a button component is Focused (by having been tabbed to, such as from a text entry box).

It seems logical to me that pressing enter while I have a button in focus, should fire off an event -- but it doesn't seem to fire ActionPerformed.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 27, 2025, 11:27pm UTC](https://forum.inductiveautomation.com/t/actionperformed-event-on-button-when-focused/104346/2 "2025-03-27T23:27:36Z")

</div>

I think it's space bar that does what you want, across all OSes.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 27, 2025, 11:33pm UTC](https://forum.inductiveautomation.com/t/actionperformed-event-on-button-when-focused/104346/3 "2025-03-27T23:33:58Z")

</div>

Oops, forgot the answer.

Add this to one of the `key` handlers:

```python
if event.keyCode == event.VK_ENTER:
	print "enter was pressed!"

```

Don't write your logic in the handler, write it in a project script. Call it from both `actionPerformed` and this handler.

---

<div class="post-metadata">

**Author:** ![Simon\_Hathout\_Willar](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@Simon\_Hathout\_Willar](https://forum.inductiveautomation.com/u/Simon_Hathout_Willar)\
**Post date:** [March 27, 2025, 11:57pm UTC](https://forum.inductiveautomation.com/t/actionperformed-event-on-button-when-focused/104346/4 "2025-03-27T23:57:26Z")

</div>

I'm not super committed to the enter key.  
I just didn't even think to try the space key, LOL.

---

<div class="post-metadata">

**Author:** ![Simon\_Hathout\_Willar](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@Simon\_Hathout\_Willar](https://forum.inductiveautomation.com/u/Simon_Hathout_Willar)\
**Post date:** [March 28, 2025, 12:01am UTC](https://forum.inductiveautomation.com/t/actionperformed-event-on-button-when-focused/104346/5 "2025-03-28T00:01:37Z")

</div>

Is there a way to interact with a lot of different components in the same project script? I grab data from 4 different fields, process it, send it to SQL, and then reset them.

I suppose I can send in the Event object, but even that wouldn't work if the events are called by different components. Maybe I could pass in the root container, and work relative to that? Or pass in each component.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 28, 2025, 12:11am UTC](https://forum.inductiveautomation.com/t/actionperformed-event-on-button-when-focused/104346/6 "2025-03-28T00:11:27Z")

</div>

> [@Simon\_Hathout\_Willar](#):
>
> Maybe I could pass in the root container, and work relative to that? Or pass in each component.

Yeah, you'll have to pass in whatever you need. There's some commonality, maybe the container, maybe all the components, that both scripts would be referencing anyway.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 28, 2025, 12:24am UTC](https://forum.inductiveautomation.com/t/actionperformed-event-on-button-when-focused/104346/7 "2025-03-28T00:24:27Z")

</div>

> [@Simon\_Hathout\_Willar](#):
>
> I suppose I can send in the Event object, but even that wouldn't work if the events are called by different components.

It does, actually. The `event` object in Vision always has a `source` property, which is the component or window that fired the event. In new-style extension methods that don't have `event`, that is handled by `self`.

Just define the least common denominator pieces as project library function arguments, and place them in the call at the origin.
