From: Rob Christiansen on

When i press a key on the keyboard, the function returns the ASCII
equivalent. That is the function i'm looking for.
Can you give me a hint??? All i have so far is charCodeAt, but that's
only good for already established strings.

crazyswede

*** Sent via Developersdex http://www.developersdex.com ***
From: nick on
On May 26, 7:39 pm, Rob Christiansen <robb_christian...(a)q.com> wrote:

> When i press a key on the keyboard, the function returns the ASCII
> equivalent.  That is the function  i'm looking for.

Unicode, not ASCII (although the keys you're pressing probably have
the same value in Unicode as the do in ASCII).

> Can you give me a hint??? All i have so far is charCodeAt, but that's
> only good for already established strings.

myChar = String.fromCharCode(myInt);
From: Stefan Weiss on
On 27/05/10 01:39, Rob Christiansen wrote:
> When i press a key on the keyboard, the function returns the ASCII
> equivalent. That is the function i'm looking for.

If you just need the keycodes for "normal" keys like letters, take a
look at this simple example:

document.onkeydown = function (evt) {
var evt = evt || window.event;
alert(evt.keyCode);
};

There are some browser and platform oddities where special keys and key
combinations are involved. For the specifics, search the web for
"onkeydown" and "onkeypress".
In a few minutes, you'll probably also get a link to an article named "K
is for Keyboard" ;)


--
stefan
From: David Mark on
On May 26, 8:42 pm, Stefan Weiss <krewech...(a)gmail.com> wrote:
> On 27/05/10 01:39, Rob Christiansen wrote:
>
> > When i press a key on the keyboard, the function returns the ASCII
> > equivalent.  That is the function  i'm looking for.
>
> If you just need the keycodes for "normal" keys like letters, take a
> look at this simple example:
>
>   document.onkeydown = function (evt) {
>     var evt = evt || window.event;
>     alert(evt.keyCode);
>   };
>
> There are some browser and platform oddities where special keys and key
> combinations are involved. For the specifics, search the web for
> "onkeydown" and "onkeypress".
> In a few minutes, you'll probably also get a link to an article named "K
> is for Keyboard" ;)
>

Why didn't you go ahead and post it? :)

http://www.cinsoft.net/keyboard.html
From: Stefan Weiss on
On 27/05/10 02:47, David Mark wrote:
> On May 26, 8:42 pm, Stefan Weiss <krewech...(a)gmail.com> wrote:
>> In a few minutes, you'll probably also get a link to an article named "K
>> is for Keyboard" ;)
>
> Why didn't you go ahead and post it? :)
>
> http://www.cinsoft.net/keyboard.html

Just wanted to demonstrate my psychic abilities :)


--
stefan