How can I catch a KeyPress event?
Hi,I want to do a test that catch the KeyPress Event or KeyDown event such like i do in JavaScript(the event name in Javascript is "onkeydown" and "onkeyup"),but i can not find the event in the developer document,can anyone tell me how? many thanks!
6 Answers
-
Any ideas? I would like to capture the 'backspace' key.
-
In what context are you trying to catch this event? If it's for a TextArea or TextField there's a 'change' event you can add a listener for.
Hope this helps,
Toby
-
I'm looking for this event to. I want to exit a fullscreen app when the user presses Esc key.
@Aaron, I know how to add an event listener. The question asked by the OP and myself is what is the event name we're supposed to attach to?
Thanks,
Brad -
I am also looking for this. Anyone find the answer?
-
add an event listener to the view the same way you would for any other object
http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.UI.addEventListener-method.html
-
The event to listen for is "change". This does the same thing as "onKeyDown" in a browser.
TextFieldName.addEventListener('change', function(e) { Ti.API.info('Text field has changed!'); });