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

Web and WebWorks Development

Reply
Regular Contributor
liammccann
Posts: 68
Registered: ‎06-12-2012
My Device: Blackberry Bold 9780
My Carrier: Vodafone

JavaScript Key Pressed Detection

Ive wrote a simple function shown below..

function handleKeyPress(showEvent,formItem){

 
if(showEvent ==null){}
elseif(showEvent.keyCode ==13)
{
   
var feildID = formItem.id;
   
var pid=formItem.parentNode.id;

   
var index = enterKeyForm[pid].indexOf(feildID);
    $
('#'+ enterKeyForm[pid][++index]).focus();
    console
.log(index);


}
else(alert(showEvent.keyCode))

}

 

This captures a key pressed well the user is on a form item, the parameters are the event and the form item , send yas onkeypress(event,this)?

But this does not fire an event for hte alt key in chrome or blackberry... But fires for all other keys...

 

This works in chrome but not blackberry If i add this code to my page to my body tag

 onkeydown="javascript:getKeys(event);"

And add this function

function getKeys(event)
{
     
if(event.altKey)
     
{  alert("The Alt key was pressed!");}
}

 

Thanks

Please use plain text.
Regular Contributor
liammccann
Posts: 68
Registered: ‎06-12-2012
My Device: Blackberry Bold 9780
My Carrier: Vodafone

Re: JavaScript Key Pressed Detection

Also i can detect alt+enter or alt+ anything
But just not alt on its own
Please use plain text.
BlackBerry Development Advisor (Retired)
astanley
Posts: 1,382
Registered: ‎07-02-2009
My Device: BlackBerry Bold 9900
My Carrier: Bell

Re: JavaScript Key Pressed Detection

I wrote this sample page to help developers understand how to capture key-press events.  It may be helpful to you in troubleshooting your problem:

 

http://blackberry.github.com/WebWorks-Samples/kitchenSink/html/browser/keyevents.html

 

 

 

 

Follow me on Twitter: @n_adam_stanley
-------------------------------------------------------------------------------------------------------------------------
Your app doesn't work? Use BlackBerry remote web inspector to find out why.
Please use plain text.
Regular Contributor
liammccann
Posts: 68
Registered: ‎06-12-2012
My Device: Blackberry Bold 9780
My Carrier: Vodafone

Re: JavaScript Key Pressed Detection

Hello.

 

This doesnt solve the problem the "alt" box up the top right of the smartphone screen is displayed which confirms its defentialey been called but it doenst fire an event.

 

Is there any other work around or solution? the alt key just doesnt seem to fire keypressed,keydown or key up on blackberry smartphone webworks applications but they are fired on the desktop fine.

 

if its any help the key $ with the volume icon on it to also doesnt fire any event, although this is no relvance as i wont be using this.

 

Thanks again...

Please use plain text.