# Which event to use when text field Enter key is pressed or focus lost?

**URL:** <https://forum.inductiveautomation.com/t/which-event-to-use-when-text-field-enter-key-is-pressed-or-focus-lost/81140>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [October 29, 2023, 8:51pm UTC](https://forum.inductiveautomation.com/t/which-event-to-use-when-text-field-enter-key-is-pressed-or-focus-lost/81140 "2023-10-29T20:51:36Z")\
**Posts on this page:** 4\
**Page:** 1

<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:** [October 29, 2023, 8:51pm UTC](https://forum.inductiveautomation.com/t/which-event-to-use-when-text-field-enter-key-is-pressed-or-focus-lost/81140/1 "2023-10-29T20:51:36Z")

</div>

I feel that this should be pretty simple but I don't remember having done it before ...

I have several text fields on a view. All of these are bound to an object in the view's custom properties. I want to update the config database table any time one of the text fields is updated - either by pressing Enter or losing focus.

What's the most intuitive other than adding a Save button? I suspect that `onCompositionEnd` is the one I want but it doesn't seem to do the business.

---

<div class="post-metadata">

**Author:** ![aaronrai24](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/aaronrai24/32/87248_2.png) [@aaronrai24](https://forum.inductiveautomation.com/u/aaronrai24)\
**Post date:** [October 30, 2023, 12:14am UTC](https://forum.inductiveautomation.com/t/which-event-to-use-when-text-field-enter-key-is-pressed-or-focus-lost/81140/2 "2023-10-30T00:14:45Z")

</div>

Have you tried [onBlur](https://docs.inductiveautomation.com/display/DOC80/Perspective+Event+Types+Reference#PerspectiveEventTypesReference-FocusEvents)? This would fire anytime you click out of the text field with the event on it, I'd probably add some check that if the text fields value hasn't changed, nothing happens, so you don't run queries just by clicking on and off the text field.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [October 30, 2023, 2:39pm UTC](https://forum.inductiveautomation.com/t/which-event-to-use-when-text-field-enter-key-is-pressed-or-focus-lost/81140/3 "2023-10-30T14:39:41Z")

</div>

You should probably just enable `deferUpdates`, and then use a change script.

---

<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:** [October 30, 2023, 5:02pm UTC](https://forum.inductiveautomation.com/t/which-event-to-use-when-text-field-enter-key-is-pressed-or-focus-lost/81140/4 "2023-10-30T17:02:01Z")

</div>

> [@cmallonee](#):
>
> ... use a change script.

That was the possibility I'd forgotten about!
