# Client event keystroke script - key release ok but not key press?

**URL:** <https://forum.inductiveautomation.com/t/client-event-keystroke-script-key-release-ok-but-not-key-press/16735>\
**Category:** Ignition\
**Created:** [January 25, 2018, 3:19pm UTC](https://forum.inductiveautomation.com/t/client-event-keystroke-script-key-release-ok-but-not-key-press/16735 "2018-01-25T15:19:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [January 25, 2018, 3:19pm UTC](https://forum.inductiveautomation.com/t/client-event-keystroke-script-key-release-ok-but-not-key-press/16735/1 "2018-01-25T15:19:56Z")

</div>

**Ignition 7.9.5 - windows 10 - Java 8**  
On a single monitor vision client, I have added the following client event script keystroke :

```auto
LEFT (Pressed)
import system
print "pressed"
```

```auto
LEFT (Released)
import system
print "released"
```

On the vision client, I clikc to the windows to set the focus,  
when I press LEFT arrow =\> no logs in diagnostics client windows =\> why ? seems to be a bug ?  
when I release LEFT arrow =\> logs “released” in diagnostics client windows.

When I reopen the LEFT client script to edit, Key F1 with Action Pressed is always displayed =\> why ???

Does any body use LEFT/RIGHT/UP/DOWN / + / - key event press and released with success ?

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [January 25, 2018, 7:27pm UTC](https://forum.inductiveautomation.com/t/client-event-keystroke-script-key-release-ok-but-not-key-press/16735/2 "2018-01-25T19:27:18Z")

</div>

Hmm… it’s working fine for me on OS X.

````auto
released
pressed
released
pressed
released```
````

---

<div class="post-metadata">

**Author:** ![acooper](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/acooper/32/4221_2.png) [@acooper](https://forum.inductiveautomation.com/u/acooper)\
**Post date:** [January 25, 2018, 8:44pm UTC](https://forum.inductiveautomation.com/t/client-event-keystroke-script-key-release-ok-but-not-key-press/16735/3 "2018-01-25T20:44:41Z")

</div>

Hi there,

I ran the same test on Windows 10, and while I am not having any trouble with the pressed action firing my script, I was able to replicate the behavior where you open the event script back up for testing, and the default of “F1” is selected in the dropdown, rather than the LEFT action. As long as I don’t apply that change, my scripts still work as expected. I wonder if you accidentally saved the changes after finding the “F1” bug. If you try pressing F1 while the vision window has focus, do your see your original “pressed” print statement?

I’ll file a bug report for the dropdown selection in the client event scripts editor. Thank you for bringing this to our attention!

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [January 29, 2018, 3:52pm UTC](https://forum.inductiveautomation.com/t/client-event-keystroke-script-key-release-ok-but-not-key-press/16735/4 "2018-01-29T15:52:56Z")

</div>

Hi @acooper,

I have recreated the script event for LEFT key, I never see the “pressed” action, only the released action is triggered.  
F1 has no effect

---

<div class="post-metadata">

**Author:** ![MikeAllgood](https://avatars.discourse-cdn.com/v4/letter/m/a183cd/32.png) [@MikeAllgood](https://forum.inductiveautomation.com/u/MikeAllgood)\
**Post date:** [September 4, 2019, 9:32pm UTC](https://forum.inductiveautomation.com/t/client-event-keystroke-script-key-release-ok-but-not-key-press/16735/5 "2019-09-04T21:32:36Z")

</div>

Sorry for digging up an old thread, but I’m having a similar issue.  
I have Keystroke scripts on the Left and Right arrows for both Pressed and Released.  
My Left arrow key pressed script looks like this:

```auto
print "setting offest subtract to TRUE"
result = system.tag.write('Midcon/HMI_Choke_Offset_Subtract', True)

```

The released script looks like this:

```auto
print "setting offest subtract to FALSE"
result = system.tag.write('Midcon/HMI_Choke_Offset_Subtract', False)

```

When pressed and released the only thing written to the Diagnostic Console is:  
“setting offest subtract to FALSE”  
Also the tag never gets set.

Has there been any follow up on this issue?

I’m running v7.9.12 in a Windows Server 2012 R2 machine.

Thanks!

---

<div class="post-metadata">

**Author:** ![sharan](https://avatars.discourse-cdn.com/v4/letter/s/258eb7/32.png) [@sharan](https://forum.inductiveautomation.com/u/sharan)\
**Post date:** [December 14, 2021, 9:51am UTC](https://forum.inductiveautomation.com/t/client-event-keystroke-script-key-release-ok-but-not-key-press/16735/6 "2021-12-14T09:51:31Z")

</div>

I have a simple code which checks for a popup window and if its open then a script written in Action performed property of a button will be executed  
the trigger is Left key . the code looks like this.

windows = system.gui.getOpenedWindowNames() # get list of all open windows  
if “Popups/205\_PopupHookupUnhookup” in windows: # check if hookupunhookup is open  
main = system.gui.getWindow(“Popups/205\_PopupHookupUnhookup”)  
button = main.getRootContainer().getComponent(“Left\_Button”) # if Yes, the point to root container of Window and the Left Button component  
button.doClick() #This will trigger code written in “actionPerformed” property of Left Button  
print windows

the Key pressed option doesn’t work with LEFT key, only released is working, is that a bug ?  
I am using ignition version 8.1.9

---

<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:** [December 14, 2021, 11:04am UTC](https://forum.inductiveautomation.com/t/client-event-keystroke-script-key-release-ok-but-not-key-press/16735/7 "2021-12-14T11:04:55Z")

</div>

Key press versus release events do vary by operating system. I recommend not relying on them.
