Probem binding keyup events

549 views
Skip to first unread message

B@ron

unread,
Aug 22, 2012, 8:55:37 AM8/22/12
to phon...@googlegroups.com
Dears,

On Android, binding keyup could not succeed in several cases.
In my application (phonegap, jquery, jquery mobile) i am using a jquery mobile search field.
When the user encode string (detected listening event keyup) and after 3 seconds a JavaScript function is executed.
It works in chrome but not on Android 4.0.4 (Phonegap cordova 2.0.0) due to the following java code

@Override
    public boolean onKeyUp(int keyCode, KeyEvent event)
    {

        LOG.d(TAG, "KeyUp has been triggered on the view"+keyCode);

        // If back key
        if (keyCode == KeyEvent.KEYCODE_BACK) {
                this.loadUrl("javascript:cordova.fireDocumentEvent('backbutton');");
                return true;
        }
        // Legacy
        else if (keyCode == KeyEvent.KEYCODE_MENU) {
            this.loadUrl("javascript:cordova.fireDocumentEvent('menubutton');");
            return true;
        }
        // If search key
        else if (keyCode == KeyEvent.KEYCODE_SEARCH) {
            this.loadUrl("javascript:cordova.fireDocumentEvent('searchbutton');");
            return true;
        }
        return false;
    }

It works when using keydown as it returns true at the end and my own process is not interrupted by the return false.

@Override
    public boolean onKeyDown(int keyCode, KeyEvent event)
    {
    	LOG.d(TAG, "KeyDown has been triggered on the view"+keyCode);
    		//If volumedown key
            if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
                    // only override default behaviour is event bound
                    LOG.d(TAG, "Down Key Hit");
                    this.loadUrl("javascript:cordova.fireDocumentEvent('volumedownbutton');");
                    return true;
            }
            // If volumeup key
            else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
                    LOG.d(TAG, "Up Key Hit");
                    this.loadUrl("javascript:cordova.fireDocumentEvent('volumeupbutton');");
                    return true;
            }
            else
            {
                //return super.onKeyDown(keyCode, event);
            }
        //return super.onKeyDown(keyCode, event);
        return true;
    }
    
Can you please correct the code or take any action regarding this problem?
++
Thibaut de Sany.

Simon MacDonald

unread,
Aug 23, 2012, 10:41:33 AM8/23/12
to phon...@googlegroups.com
I believe this is already fixed. What version of PhoneGap are you using?

Simon Mac Donald
http://hi.im/simonmacdonald
> --
> -- You received this message because you are subscribed to the Google
> Groups "phonegap" group.
> To post to this group, send email to phon...@googlegroups.com
> To unsubscribe from this group, send email to
> phonegap+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/phonegap?hl=en?hl=en
>
> For more info on PhoneGap or to download the code go to www.phonegap.com
>
> To compile in the cloud, check out build.phonegap.com
>
>

Milky Boy

unread,
Sep 6, 2012, 11:30:48 AM9/6/12
to phon...@googlegroups.com
Dear,

I am facing the same problem. keyup does not respond ! I am using cordova 2.0.0. Aka latest stable.
Is this fixed in the 2.0.1 rc or something?

Thanks !
Miloud

Alejandro Sack

unread,
Jul 5, 2013, 6:17:38 AM7/5/13
to phon...@googlegroups.com
With version 2.3.0 works fine!
Reply all
Reply to author
Forward
0 new messages