MBC Computer Solutions Ltd.

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Wednesday, 14 November 2007

MS AJAX Sys.UI.DomEvent documentation missing keyCode property

Posted on 12:07 by Unknown

If you've ever reviewed the JavaScript source code for some MS AJAX-based components like the AJAX Control Toolkit, you might have noticed the use of the Sys.UI.DomEvent.keyCode property in a number of places to handle keyboard input in controls.  I had recalled that there was also a charCode property on the same class, so interested in what the difference was, I headed over to http://asp.net/AJAX/Documentation/Live/ClientReference/Sys.UI/DomEventClass/default.aspx to take a look at the official documentation, but to my surprise, there was no keyCode property listed.

My initial reaction was that this was either an internal field or something that had been deprecated in the RTM, yet there are references to it in the target property too.  What I ultimately discovered is that this is a simple omission in the documentation.

Now back to why I was looking it up in the first place - what exactly is the difference between charCode and keyCode? Patrick Long has a blog entry at http://blogs.charteris.com/blogs/patl/archive/2007/07/04/keycodes-charcodes-and-asp-net-ajax.aspx that sums it all up nicely; charCode will return a value related to the character being pressed whereas keyCode is related to the key being pressed.  For example, 7 on the number pad and 7 on the QWERTY pad will return different keyCode values but the same charCode values.

Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Posted in | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

Blog Archive

  • ►  2012 (1)
    • ►  February (1)
  • ►  2010 (1)
    • ►  April (1)
  • ►  2009 (7)
    • ►  December (1)
    • ►  November (1)
    • ►  October (1)
    • ►  July (1)
    • ►  April (2)
    • ►  February (1)
  • ►  2008 (36)
    • ►  November (3)
    • ►  October (2)
    • ►  September (1)
    • ►  August (1)
    • ►  July (2)
    • ►  June (6)
    • ►  May (4)
    • ►  April (1)
    • ►  March (4)
    • ►  February (7)
    • ►  January (5)
  • ▼  2007 (35)
    • ►  December (1)
    • ▼  November (9)
      • Fixing the window resize event in IE
      • Recursively finding controls - where to start?
      • Don't store request variables in the ViewState!
      • Apple Warranty's aren't so hot
      • MS AJAX Sys.UI.DomEvent documentation missing keyC...
      • Widescreen resolutions & DVI
      • Windows Live Writer is Here!
      • Paul Thurrott's "Inside Windows Server 2008"
      • Mac Trojan In the Wild
    • ►  October (3)
    • ►  September (6)
    • ►  August (7)
    • ►  July (9)
  • ►  2006 (3)
    • ►  May (3)
Powered by Blogger.

About Me

Unknown
View my complete profile