By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,528 Members | 1,338 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,528 IT Pros & Developers. It's quick & easy.

Problem with javascript keydown event

P: 2
Hello friends,

I am facing a very strange problem with the Keydown() event.

I have a textbox on my page. When ever a key is down on the textbox, I am calling a javascript function to display the character.

Expand|Select|Wrap|Line Numbers
  1. function monitorKeys(event)
  2. {
  3.   alert(event.keyCode); //This is displaying 219 for [ (opening square bracket)
  4.   alert(String.fromCharCode(event.keyCode))// This is displaying a weird Unicode  character
  5. }
I know that the event.keyCode will return the Unicode number on IE, but how can I convert it back to the original character?

I sincerely appreciate your help on this.
Feb 13 '09 #1
Share this Question
Share on Google+
3 Replies


acoder
Expert Mod 15k+
P: 16,027
Browsers have differences with respect to the key and character pressed during onkeypress/up/down. This link should cover most of them.
Feb 14 '09 #2

P: 2
Thanks Acoder, the link is very informative.
Feb 14 '09 #3

acoder
Expert Mod 15k+
P: 16,027
You're welcome. Glad you found it useful.
Feb 14 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.