Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Developer
Posts: 27
Registered: ‎05-20-2012
My Device: Dev Alpha B, C and Playbook
My Carrier: PLAY

Key event duration property returns something strange

keyListeners: [
            KeyListener {
                id:listener
                onKeyEvent: { 
                }
                
                onKeyPressed: {  
                    
                }
                
                onKeyReleased: {  
                    console.log("dur "+event.duration);
                }
            }

 It suppose to return time of pressing a key, but it returns random number like: 1 or 2 or 0 (mostly). It doesnt matter how long I press (even 10 sec or more). What's wrong? 

 

Cheers!

Retired
Posts: 252
Registered: ‎08-17-2012
My Device: BlackBerry Z10 and Q10
My Carrier: Bell

Re: Key event duration property returns something strange

Hi RichardRahl,

 

The KeyEvent.duration() function is meant only to return the duration in milliseconds that the key has been held in a pressed state. Checkout the API reference here. I suggest you check first that isPressed is true, i.e. (if event.isPressed).

 

 

@SamarAbdelsayed

Did this answer your question? Please accept post as solution.
Please refrain from posting new questions in solved threads.
Found a bug? Report it using the Issue Tracker