0

How to intercept the Enter Key in Textbox?

asked 2009-09-04 23:30:31 +0800

windeyu gravatar image windeyu flag of United States
288 3

updated 2009-09-04 23:35:09 +0800

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 flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2009-09-07 05:37:57 +0800

baskaraninfo gravatar image baskaraninfo
526 2 2 9

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

component.addEventListener("onOK", this);

link publish delete flag offensive edit

answered 2009-09-08 17:44:41 +0800

windeyu gravatar image windeyu flag of United States
288 3

That works. Thank you, baskaraninfo.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-09-04 23:30:31 +0800

Seen: 554 times

Last updated: Sep 08 '09

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More