# Capture KeyPress on popup

**URL:** <https://forum.inductiveautomation.com/t/capture-keypress-on-popup/84139>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [January 11, 2024, 6:11pm UTC](https://forum.inductiveautomation.com/t/capture-keypress-on-popup/84139 "2024-01-11T18:11:13Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pat\_Cunningham](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pat_cunningham/32/57710_2.png) [@Pat\_Cunningham](https://forum.inductiveautomation.com/u/Pat_Cunningham)\
**Post date:** [January 11, 2024, 6:11pm UTC](https://forum.inductiveautomation.com/t/capture-keypress-on-popup/84139/1 "2024-01-11T18:11:13Z")

</div>

How can I capture a key press on a popup?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [January 11, 2024, 6:20pm UTC](https://forum.inductiveautomation.com/t/capture-keypress-on-popup/84139/2 "2024-01-11T18:20:58Z")

</div>

Right-click → Configure Events → onKeyDown / onKeyPress / onKeyUp.

---

<div class="post-metadata">

**Author:** ![Pat\_Cunningham](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pat_cunningham/32/57710_2.png) [@Pat\_Cunningham](https://forum.inductiveautomation.com/u/Pat_Cunningham)\
**Post date:** [January 11, 2024, 6:22pm UTC](https://forum.inductiveautomation.com/t/capture-keypress-on-popup/84139/3 "2024-01-11T18:22:11Z")

</div>

I already did that but let me double check my code for errors.

I created the keypad below and I need the user to be able to enter numbers and except from the keyboard. I also need to select the password field (which isn't working) without the autocomplete.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/c/2c7373fc83a322e20888cb78e25d5c66879b3723.png)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [January 11, 2024, 6:23pm UTC](https://forum.inductiveautomation.com/t/capture-keypress-on-popup/84139/4 "2024-01-11T18:23:35Z")

</div>

Paste the view so we can try it out.

---

<div class="post-metadata">

**Author:** ![Pat\_Cunningham](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pat_cunningham/32/57710_2.png) [@Pat\_Cunningham](https://forum.inductiveautomation.com/u/Pat_Cunningham)\
**Post date:** [January 11, 2024, 6:36pm UTC](https://forum.inductiveautomation.com/t/capture-keypress-on-popup/84139/5 "2024-01-11T18:36:15Z")

</div>

I tried writing the keycode to a label on the popup and nothing

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/c/2ce9fdb0825d3b1f399fec9aab0a9ba9738b8e26.png)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [January 11, 2024, 6:55pm UTC](https://forum.inductiveautomation.com/t/capture-keypress-on-popup/84139/6 "2024-01-11T18:55:51Z")

</div>

No, select the view in Project Browser, right-click, copy and paste it in here and format it using the \</\> button.

What are you expecting that script to do? At best it's going to overwrite whatever was there with the keyCode.

---

<div class="post-metadata">

**Author:** ![Pat\_Cunningham](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pat_cunningham/32/57710_2.png) [@Pat\_Cunningham](https://forum.inductiveautomation.com/u/Pat_Cunningham)\
**Post date:** [January 11, 2024, 7:06pm UTC](https://forum.inductiveautomation.com/t/capture-keypress-on-popup/84139/7 "2024-01-11T19:06:16Z")

</div>

I have to take screenshots because I am working in a high security area and getting code out is very difficult.  
I tried this and I am getting nothing. I have to be doing something very wrong.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/2/32340ef3330586b2e395666d4026e510690a0365.png)

---

<div class="post-metadata">

**Author:** ![Pat\_Cunningham](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pat_cunningham/32/57710_2.png) [@Pat\_Cunningham](https://forum.inductiveautomation.com/u/Pat_Cunningham)\
**Post date:** [January 11, 2024, 7:28pm UTC](https://forum.inductiveautomation.com/t/capture-keypress-on-popup/84139/8 "2024-01-11T19:28:40Z")

</div>

I was able to get the session event to work but I can't specify which page

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [January 11, 2024, 8:00pm UTC](https://forum.inductiveautomation.com/t/capture-keypress-on-popup/84139/9 "2024-01-11T20:00:15Z")

</div>

Have a look at Perspective Keypad on [Ignition Exchange | Inductive Automation](https://inductiveautomation.com/exchange/1521/). It was written by @cmallonee of IA who frequents the forum. If it doesn't do exactly what you want it may give you some ideas. I haven't tried it.

See also,

> **[Ignition Exchange](https://inductiveautomation.com/exchange/2176/overview)**
>
> Discover, share, and download community made Ignition resources in collaboration with your organization or the Ignition community.

> **[Home | AO Automation](https://www.aoautomation.io/blog/tutorials-lessons-learned-1/perspective-number-keypad-3)**

---

<div class="post-metadata">

**Author:** ![Pat\_Cunningham](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pat_cunningham/32/57710_2.png) [@Pat\_Cunningham](https://forum.inductiveautomation.com/u/Pat_Cunningham)\
**Post date:** [January 11, 2024, 8:13pm UTC](https://forum.inductiveautomation.com/t/capture-keypress-on-popup/84139/10 "2024-01-11T20:13:44Z")

</div>

I don't understand why there are Keyboard Events if none of them actually do anything. Like I said I got the session Keyboard Event to work but there is no way to identify which view is being displayed.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [January 11, 2024, 8:28pm UTC](https://forum.inductiveautomation.com/t/capture-keypress-on-popup/84139/11 "2024-01-11T20:28:13Z")

</div>

Did you notice the line in [Perspective Session Event Scripts - Ignition User Manual 8.1 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC81/Perspective+Session+Event+Scripts#PerspectiveSessionEventScripts-Keystroke) (Keystrokes section)?

> Keystroke detection is only active inside of a Perspective session and is not active inside of the Designer.

---

<div class="post-metadata">

**Author:** ![Pat\_Cunningham](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pat_cunningham/32/57710_2.png) [@Pat\_Cunningham](https://forum.inductiveautomation.com/u/Pat_Cunningham)\
**Post date:** [January 11, 2024, 8:38pm UTC](https://forum.inductiveautomation.com/t/capture-keypress-on-popup/84139/12 "2024-01-11T20:38:23Z")

</div>

I did. The session events work I just have no way of determining what view is active when the event fires.

If I use the event on a view I just discovered that if I click into a text field on the view it starts to capture. If I click off the text field it stops.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [January 11, 2024, 8:40pm UTC](https://forum.inductiveautomation.com/t/capture-keypress-on-popup/84139/13 "2024-01-11T20:40:10Z")

</div>

I would have expected to have to create an event on each keypad key.
