# BUG?: Strange behaviour while comparing two strings in component event script

**URL:** <https://forum.inductiveautomation.com/t/bug-strange-behaviour-while-comparing-two-strings-in-component-event-script/89877>\
**Category:** Ignition\
**Tags:** scripting, vision, ignition81\
**Created:** [May 3, 2024, 8:35am UTC](https://forum.inductiveautomation.com/t/bug-strange-behaviour-while-comparing-two-strings-in-component-event-script/89877 "2024-05-03T08:35:42Z")\
**Posts on this page:** 3\
**Page:** 3

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [May 6, 2024, 3:15pm UTC](https://forum.inductiveautomation.com/t/bug-strange-behaviour-while-comparing-two-strings-in-component-event-script/89877/41 "2024-05-06T15:15:52Z")

</div>

Possibly, custom properties can function much the same, they just don't persist across Gateway Restarts.

---

<div class="post-metadata">

**Author:** ![Bushmatic](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bushmatic/32/87014_2.png) [@Bushmatic](https://forum.inductiveautomation.com/u/Bushmatic)\
**Post date:** [May 6, 2024, 3:23pm UTC](https://forum.inductiveautomation.com/t/bug-strange-behaviour-while-comparing-two-strings-in-component-event-script/89877/42 "2024-05-06T15:23:20Z")

</div>

> [@Om33](#):
>
> Update:  
> when I remove the `event.keyCode==event.VK_ENTER:` at the beginning of script, it works.

The issues with the keyPressed event remind me of similar issues I had with this event handler... Shot in the dark here, but are you pressing the same enter key each time? For example, numpad enter vs. "normal" enter? I had to change:

```python
if event.keyCode == event.VK_ENTER:

```

...to:

```python
if event.keyCode == 10:

```

...in order to get my keyPressed events to work properly with any enter key. `VK_ENTER` was not working with numpad enter in my scripts. Something small to consider...

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [May 7, 2024, 3:05am UTC](https://forum.inductiveautomation.com/t/bug-strange-behaviour-while-comparing-two-strings-in-component-event-script/89877/43 "2024-05-07T03:05:25Z")

</div>

> [@Bushmatic](#):
>
> `event.keyCode == event.VK_ENTER`

The keyCode should be the same for any enter key. If a developer needs a key event to only occur for a specific key where there are more than one of the same type on the keyboard, then event.keyLocation is used to differentiate.

**Example:**

```python
if event.keyCode == event.VK_ENTER and event.keyLocation == event.KEY_LOCATION_NUMPAD:
	print 'This only works for the enter key on the number pad'
	
if event.keyCode == event.VK_ENTER and event.keyLocation == event.KEY_LOCATION_STANDARD:
	print 'This only works for the enter key on the standard keypad'

```

If `event.keyCode == event.VK_ENTER` isn't working universally for enter, I would call that an unexpected behavior that should be reported.

[Previous page](https://forum.inductiveautomation.com/t/bug-strange-behaviour-while-comparing-two-strings-in-component-event-script/89877.md?page=2)
