determining letter or digit on keydown

P

PJ6

I can probably do this by mapping out all the number and letter key codes...
but I was just wondering if there is a built-in JavaScript function that can
determinine if the key pressed in the keydown event is a letter or a digit.
Or, more specifically to my functional requirement, a key that will affect
the contents of an input of type text. So I guess that plus backspace and
delete.

TIA,
Paul
 
E

Evertjan.

PJ6 wrote on 03 dec 2005 in comp.lang.javascript:
I can probably do this by mapping out all the number and letter key
codes... but I was just wondering if there is a built-in JavaScript
function that can determinine if the key pressed in the keydown event
is a letter or a digit. Or, more specifically to my functional
requirement, a key that will affect the contents of an input of type
text. So I guess that plus backspace and delete.

You are not telling what you mean by "do this", but altering the
functionality of the ext input field risks the penalty of users becoming
frustrated and going runnu=ing to other sites.

If you must, play with

<input onkeypress='alert(event.keyCode)'>

and see the ascii output enacted.

Then try:

<input onkeypress='var e=event.keyCode;return (e>47)&&(e<59)'>
 
P

PJ6

You are not telling what you mean by "do this",

The subject of the post, "determining letter or digit on keydown".
but altering the
functionality of the ext input field risks the penalty of users becoming
frustrated and going runnu=ing to other sites.

You assume that I'm altering behavior apparent to the user and that I'm
working on a site that's selling something, neither of which is true.
If you must, play with

<input onkeypress='alert(event.keyCode)'>

and see the ascii output enacted.

Yeah. That's what I specifically said that I could do but would rather
avoid.

Paul
 
E

Evertjan.

PJ6 wrote on 03 dec 2005 in comp.lang.javascript:
The subject of the post, "determining letter or digit on keydown".


You assume that I'm altering behavior apparent to the user and that
I'm working on a site

What non-apparent function would you device?

that's selling something, neither of which is true.

I did not, but let it be.
Yeah. That's what I specifically said that I could do but would rather
avoid.

What would you avoid? Finding out the function yourself?

You skip my final solution:
Then try:

<input onkeypress='var e=event.keyCode;return (e>47)&&(e<59)'>

Is this not what you want?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top