# Action after enter key on a text field

**URL:** <https://forum.xojo.com/t/action-after-enter-key-on-a-text-field/43227>\
**Category:** General\
**Created:** [April 27, 2018, 11:09pm UTC](https://forum.xojo.com/t/action-after-enter-key-on-a-text-field/43227 "2018-04-27T23:09:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![James\_M\_Wadkins](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@James\_M\_Wadkins](https://forum.xojo.com/u/James_M_Wadkins)\
**Post date:** [April 27, 2018, 11:09pm UTC](https://forum.xojo.com/t/action-after-enter-key-on-a-text-field/43227/1 "2018-04-27T23:09:42Z")

</div>

Hi Folks,  
I am tinkering again with a small project. I have a textfield where you enter a string of text, say 98AB and hit enter, then the app would do ‘X’ processes. I have tried using the TextChange Event Handler, but when you enter the first character 9 from above, it then starts the action instead of waiting for the entire string 98AB to be entered. I also tried the LostFocus Event Handler and tabbing away, but that did not work…

[code]dim text1 as string

text1.text = textfield.text

‘Do "X’ command[/code]

Is there a way to do this?

---

<div class="post-metadata">

**Author:** ![Roger\_Clary](https://forum.xojo.com/letter_avatar_proxy/v4/letter/r/eada6e/32.png) [@Roger\_Clary](https://forum.xojo.com/u/Roger_Clary)\
**Post date:** [April 27, 2018, 11:18pm UTC](https://forum.xojo.com/t/action-after-enter-key-on-a-text-field/43227/2 "2018-04-27T23:18:34Z")

</div>

In keydown event…

If `key = chr(13) or key = chr(3) then
  //do whatever
   Return true
Else
   Return false
End If
`

---

<div class="post-metadata">

**Author:** ![James\_M\_Wadkins](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@James\_M\_Wadkins](https://forum.xojo.com/u/James_M_Wadkins)\
**Post date:** [April 27, 2018, 11:43pm UTC](https://forum.xojo.com/t/action-after-enter-key-on-a-text-field/43227/3 "2018-04-27T23:43:42Z")

</div>

Thank you Roger, this worked perfectly.

---

<div class="post-metadata">

**Author:** ![Byron\_Minick](https://forum.xojo.com/user_avatar/forum.xojo.com/byron_minick/32/869_2.png) [@Byron\_Minick](https://forum.xojo.com/u/Byron_Minick)\
**Post date:** [October 23, 2019, 7:39pm UTC](https://forum.xojo.com/t/action-after-enter-key-on-a-text-field/43227/4 "2019-10-23T19:39:10Z")

</div>

Thank you! This solved my question too… 😉

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 7:11pm UTC](https://forum.xojo.com/t/action-after-enter-key-on-a-text-field/43227/5 "2020-10-29T19:11:50Z")

</div>


