Solved

Intercept Key events in a Black Berry with JavaScript

Posted on 2009-07-03
3
247 Views
Last Modified: 2012-05-07
I'm trying to intercept key events using javascript.

In my script im getting the unicode like this:

 

 var unicode=evtobj.charCode? evtobj.charCode : evtobj.keyCode

 

and validating it with a IF statement for  example:

 

   if (unicode==50)
                       
                                     
                  do something ...                

                   
                Although in PC browsers this works  fine in the BlackBerry doesn't ... I have tried in Nokia and LG phones and works perfectly, Is there  another way to do this? because i can figure out that BlackBerry doesn't support these kind of instructions...
0
Comment
Question by:Veljean
  • 2
3 Comments
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 24775451
Veljean,

Have you verified Javascript works?  Add an alert or some script to the event to see if it even exists.  If it does then you might try ...

var unicode=evtobj.charCode? evtobj.charCode : (evtobj.keyCode)? evtobj.keyCode : evtobj.which;

Let me know if you have any questions or need more information.

b0lsc0tt
0
 
LVL 1

Author Comment

by:Veljean
ID: 24786962
Yes b0Isc0tt , the option  "JS enabled"  is already checked in my BlackBerry  , and I added an alert to the event to see what happens without success, like I said in a nomal PC browser and other cellphones (not blackberry) the script works perfectly. I will try your statement as soon as I can (unfortunately today I have run into  other issues that make impossible to test it) I hope we can keep us in touch...
0
 
LVL 54

Accepted Solution

by:
b0lsc0tt earned 125 total points
ID: 24788519
Let me know how that line works but the issue may still be general javascript support.  If you tried the alert and it didn't work then that is a sign Javascript isn't working or has very limited support.  The code below in the snippet would be good to use as a test (place it in between the body tags somewhere).  Let me know what you get by testing the line below.
bol

<script type="javascript">

document.write "This is a test line.<br>";

</script>

Open in new window

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now