Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Key Codes for some keyboard buttons

Reply
Thread Tools

Key Codes for some keyboard buttons

 
 
Additya
Guest
Posts: n/a
 
      01-22-2010
This tutorial will show you how to get the pressed key in the browser
window, whether it's Ctrl, Alt, Shift, Page Up, Arrow Up or any other
key. There's both an Internet Explorer and a Firefox way of doing
this.

http://www.ezdia.com/Key_Codes_for_s...tent.do?id=782

There are several reasons why you may want to capture the key press
event in a browser window. Perhaps you're making a JavaScript game, or
a map similar to Google Maps and you want to allow navigation through
the arrow keys. Getting the pressed key is easy in JavaScript, however
different browsers use different ways for this
 
Reply With Quote
 
 
 
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      01-22-2010
Additya wrote:

> This tutorial will show you how to get the pressed key in the browser
> window, whether it's Ctrl, Alt, Shift, Page Up, Arrow Up or any other
> key. There's both an Internet Explorer and a Firefox way of doing
> this.
>
>

http://www.ezdia.com/Key_Codes_for_s...tent.do?id=782

Utter nonsense. Ctrl, Alt, and Shift are detected with the ctrlKey,
altKey, and shiftKey event properties respectively, `keyCode' is not
reliable, proprietary event-handler properties are used, Opera or WebKit
are not considered at all, proprietary control referencing is used, and the
markup is invalid XHTML or HTML. Oh yes, and code written 2005(!) to
handle "Internet Explorer and Firefox" is very relevant today, isn't it?

Of course, none of the half-wits replying there could have possibly
recognized any of that, only that it would be "working well" (it doesn't)
or that it "(still) does not work" (of course it doesn't). Blind leading
the blind.

For getting a good idea and rather up-to-date information on how hard it
really is to handle keyboard events cross-DOM/cross-browser, read
<http://unixpapa.com/js/key.html> instead.


PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)
 
Reply With Quote
 
 
 
 
David Mark
Guest
Posts: n/a
 
      01-22-2010
Thomas 'PointedEars' Lahn wrote:

[...]

>
> For getting a good idea and rather up-to-date information on how hard it
> really is to handle keyboard events cross-DOM/cross-browser, read
> <http://unixpapa.com/js/key.html> instead.
>


I haven't read the article, but I can tell you it isn't hard to do
cross-browser keyboard monitoring. I had never had a call for it until
recently and was pleasantly surprised at how trivial it turned out to
be. Yes, that script will likely end up in My Library as
attachKeyboardListeners (or something like that). It is already part of
the upcoming sequel.
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      01-22-2010
David Mark wrote:

> Thomas 'PointedEars' Lahn wrote:
>> For getting a good idea and rather up-to-date information on how hard it
>> really is to handle keyboard events cross-DOM/cross-browser, read
>> <http://unixpapa.com/js/key.html> instead.

>
> I haven't read the article,


You should.

> but I can tell you it isn't hard to do cross-browser keyboard monitoring.


I don't think you are already in a position to make that assessment.

> I had never had a call for it until recently and was pleasantly surprised
> at how trivial it turned out to be. Yes, that script will likely end up
> in My Library as attachKeyboardListeners (or something like that). It is
> already part of the upcoming sequel.


I'd be positively surprised if it did as advertised.


PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$(E-Mail Removed)>
 
Reply With Quote
 
David Mark
Guest
Posts: n/a
 
      01-22-2010
Thomas 'PointedEars' Lahn wrote:
> David Mark wrote:
>
>> Thomas 'PointedEars' Lahn wrote:
>>> For getting a good idea and rather up-to-date information on how hard it
>>> really is to handle keyboard events cross-DOM/cross-browser, read
>>> <http://unixpapa.com/js/key.html> instead.

>> I haven't read the article,

>
> You should.


Why? I don't need help with it.

>
>> but I can tell you it isn't hard to do cross-browser keyboard monitoring.

>
> I don't think you are already in a position to make that assessment.


How would you know?

>
>> I had never had a call for it until recently and was pleasantly surprised
>> at how trivial it turned out to be. Yes, that script will likely end up
>> in My Library as attachKeyboardListeners (or something like that). It is
>> already part of the upcoming sequel.

>
> I'd be positively surprised if it did as advertised.
>


What did I advertise and have I ever failed to surprise?
 
Reply With Quote
 
Scott Sauyet
Guest
Posts: n/a
 
      01-22-2010
On Jan 22, 11:09*am, David Mark <(E-Mail Removed)> wrote:
> [H]ave I ever failed to surprise?


Continually. Of course you could shock everyone here by endorsing
MooTools!

-- Scott
 
Reply With Quote
 
David Mark
Guest
Posts: n/a
 
      01-22-2010
Scott Sauyet wrote:
> On Jan 22, 11:09 am, David Mark <(E-Mail Removed)> wrote:
>> [H]ave I ever failed to surprise?

>
> Continually.


What is obvious to some is often surprising to others.

> Of course you could shock everyone here by endorsing
> MooTools!
>


Now that would be a surprise. Mootools is just another 50-100K of JS
that is _constantly_ changed by various deluded hacks and occasionally
crystallizes into something that appears to work in three or four of the
latest browsers (in their default configurations). How is that worth...
anything? And it's a _really_ stupid name too. I'm trying to imagine
corporate IT types dropping that into a conversation. Can't do it.
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      01-24-2010
David Mark wrote:

> Thomas 'PointedEars' Lahn wrote:
>> David Mark wrote:
>>> Thomas 'PointedEars' Lahn wrote:
>>>> For getting a good idea and rather up-to-date information on how hard
>>>> it really is to handle keyboard events cross-DOM/cross-browser, read
>>>> <http://unixpapa.com/js/key.html> instead.
>>> I haven't read the article,

>> You should.

>
> Why? I don't need help with it.


I don't think you ... wait, this thread is at the verge of getting
recursive. We better end it while we still can.

>>> but I can tell you it isn't hard to do cross-browser keyboard
>>> monitoring.

>> I don't think you are already in a position to make that assessment.

>
> How would you know?


You have not read the article yet.

>>> I had never had a call for it until recently and was pleasantly
>>> surprised at how trivial it turned out to be. Yes, that script will
>>> likely end up in My Library as attachKeyboardListeners (or something
>>> like that). It is already part of the upcoming sequel.

>> I'd be positively surprised if it did as advertised.

>
> What did I advertise


That your code/My Library can do "cross-browser keyboard monitoring".

> and have I ever failed to surprise?


No; sometimes unfortunately.


PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to write codes to connect access database using html codes hiralcp Software 0 12-18-2007 08:49 PM
How to use file I/o codes with form and controls codes Allen ASP .Net 1 12-03-2007 12:04 AM
Virtual Key Codes, Scan Codes and ASCII Codes in C gj_williams2000@yahoo.co.uk C Programming 2 08-20-2005 11:04 AM
RegEx replace of html codes to ascii codes Greg -- ASP .Net 4 08-09-2005 07:27 PM
2 buttons but want enter key in textbox to execute one buttons' click event? Roger ASP .Net 1 05-20-2005 09:47 PM



Advertisments