# How to intercept the Enter Key in Textbox?

windeyu
288 3

I tried adding an EventListener of "onChanging" type to a Textbox, but the listener doesn't get invoked when the user presses the Enter key inside the Textbox. How do I intercept the Enter key event?

An ugly incomplete solution I attempted is to make the textbox multiline=true rows=1, which will invoke my listener when the Enter-key puts '\n' to the textbox. However, I have to immediately remove '\n' from the textbox, which causes a visual jumping of the text inside the single-line textbox.

Thanks in advance for any better solution.
windeyu

delete retag edit

## 2 Replies

526 2 2 9

You can extend EventListener and register for onOK event, to listen for ENTER event:

component.addEventListener("onOK", this);

windeyu
288 3

[hide preview]