Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

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!

— asked October 7th 2010 by Wen Bin
  • keppress
  • keydown
0 Comments

6 Answers

  • Any ideas? I would like to capture the 'backspace' key.

    — answered February 16th 2012 by Gertjan Smits
    permalink
    0 Comments
  • 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

    — answered October 8th 2010 by Toby Mathews
    permalink
    2 Comments
    • Thanks Toby,but I want to control an object(such like a View) move by keyboard,how can I do that?

      — commented October 8th 2010 by Wen Bin
    • e.value here returns All the TextField/Area's value… not the last Key Pressed.

      — commented April 13th 2015 by Joseph Sachs
  • 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

    — answered November 6th 2010 by Brad Ramsey
    permalink
    0 Comments
  • I am also looking for this. Anyone find the answer?

    — answered February 15th 2011 by Patrick Ballantyne
    permalink
    0 Comments
  • 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

    — answered October 29th 2010 by Aaron Saunders
    permalink
    0 Comments
  • 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!');
    });
    
    — answered December 29th 2011 by Jens Lorentsson
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.