# event.VK\_ENTER with confirmation dialogue

**URL:** <https://forum.inductiveautomation.com/t/event-vk-enter-with-confirmation-dialogue/6768>\
**Category:** Ignition\
**Created:** [June 26, 2013, 1:29pm UTC](https://forum.inductiveautomation.com/t/event-vk-enter-with-confirmation-dialogue/6768 "2013-06-26T13:29:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![quper](https://avatars.discourse-cdn.com/v4/letter/q/aeb1de/32.png) [@quper](https://forum.inductiveautomation.com/u/quper)\
**Post date:** [June 26, 2013, 1:29pm UTC](https://forum.inductiveautomation.com/t/event-vk-enter-with-confirmation-dialogue/6768/1 "2013-06-26T13:29:24Z")

</div>

Hello,

I have Numeric Text Field which has event on keyReleased:

`if event.keyCode == event.VK_ENTER:
	value = event.source.floatValue
	tagPath=event.source.TagPath
	if system.gui.confirm('Are You sure?', 'Confirm'):
		system.tag.writeToTag(tagPath, value)
	else:
		event.source.floatValue=system.tag.getTagValue(tagPath)`

When I change the value of this Numeric Text Field and press Enter, confirmation dialogue pops up.  
If I use mouse click to operate ‘Yes’ ‘No’ buttons on confirmation dilaogue, everything works fine.  
But if I use Enter on confirmation dialogue, my event script works again. It means that event on confirmation dialogue is actually Numeric Text Field event.  
Is it possible to separate those events somehow?

---

<div class="post-metadata">

**Author:** ![dave.fogle](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@dave.fogle](https://forum.inductiveautomation.com/u/dave.fogle)\
**Post date:** [June 27, 2013, 5:58pm UTC](https://forum.inductiveautomation.com/t/event-vk-enter-with-confirmation-dialogue/6768/2 "2013-06-27T17:58:46Z")

</div>

Is there a reason you have the script on the key released event? If not then try putting the script under the key pressed event. The key pressed event should avoid the behavior that you're currently seeing.

---

<div class="post-metadata">

**Author:** ![quper](https://avatars.discourse-cdn.com/v4/letter/q/aeb1de/32.png) [@quper](https://forum.inductiveautomation.com/u/quper)\
**Post date:** [July 9, 2013, 6:23am UTC](https://forum.inductiveautomation.com/t/event-vk-enter-with-confirmation-dialogue/6768/3 "2013-07-09T06:23:18Z")

</div>

Thanks.  
But unfortunatelly it doesn’t work as it should under key pressed.  
In this case if I enter value and confirm with Enter key, value will be displayed in Numeric text field, but will not be written to tag. If I enter some other value and confirm, previous input will be written.

---

<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:** [August 12, 2013, 10:32pm UTC](https://forum.inductiveautomation.com/t/event-vk-enter-with-confirmation-dialogue/6768/4 "2013-08-12T22:32:47Z")

</div>

What you’re doing is inherently risky.

What happens if they alter the value and tab away instead of hitting enter?

I think you’d be better off designing some sort of confirm-before-write template that used a display field, a button to enter “edit mode” and a button to commit the write or something like that…
