Results 1 to 6 of 6
  1.    #1  
    I've added key listeners to the window object. I want to be able to capture any key events and print them into a div, NOT into a text box (I don't use text boxes). For some reason, the key listeners are never fired! Any idea what I'm doing wrong?

    Code:
    var thisObj = this;
    
    //Everything but enter key
    		window.addEventListener( "keypress", 
    			function(event)
    			{
    				thisObj.keyListener( event )
    			},
    			true
    		);
    		
    		//Modifier keys
    		window.addEventListener( "keydown", 
    			function(event)
    			{
    				thisObj.modifierKeyListener( event )
    			},
    			true
    		);
    		
    		//Enter key
    		window.addEventListener( "keyup", 
    			function(event)
    			{
    				thisObj.clearModifierKeyListener( event )
    			},
    			true
    		);
    The keyup and keydown events are both fired but not the keypress!
  2. #2  
    Try one of these;
    Mojo.Event.keydown
    Mojo.Event.keypress
    Mojo.Event.keyup

    And I'm not sure if you should bind those on the 'window' object but like i said, not sure about that one.

    p.s. also you might want to try using the controller's "listen" method and Function.bind. something as;
    Code:
    this.controller.listen( object, Mojo.Event.keypress, this.yourMethod.bind(this);
    Where object could be Window, and yourMethod is a method within the controller, and using bind(this) you make sure it stays in the right scope.
    My Palm History (in order): IIIe SE, m130, Tungsten|T, m505, Tungsten|T3, Zire 71, m505 (owned two different ones), Zire 72, Tungsten|C, T|X, Treo 650.
    After that I got a Apple iPhone 3G, Palm Pre (GSM), Google Nexus One.
  3. #3  
    And go ahead and do it properly to remove the handler:

    Code:
    this.keyHdlr = thie.yourMethod.bind(this);
    this.controller.listen( object, Mojo.Event.keypress, this.keyHdlr );
    
    // Inside cleanup
    this.controller.stopListening( object, Mojo.Event.keypress, this.keyHdlr );
    Your Pre wants Word Whirl from the App Catalog.

    It told me.
  4.    #4  
    Thanks! I think the issue is that there is no keypress event thrown. instead mojo makes a keypress event when a keyup is thrown after a keydown, unlike in most browsers where there is a keypress event.
  5.    #5  
    Now I'm getting another error:

    TypeError: Object #<an anonymous> has no method 'listen'

    I used this code:

    this.controller.listen( window, Mojo.Event.keypress, this.keyListener.bind( this ), true );
  6. #6  
    Then you are probably in the wrong scope, where are you writing this? You should bind events in the setup() method of your view's assistant Javascript file.

    This is a good place to start learning...
    Hello World – webOSdev – Palm
    My Palm History (in order): IIIe SE, m130, Tungsten|T, m505, Tungsten|T3, Zire 71, m505 (owned two different ones), Zire 72, Tungsten|C, T|X, Treo 650.
    After that I got a Apple iPhone 3G, Palm Pre (GSM), Google Nexus One.

Posting Permissions