keyboard events and characters

C

Csaba Gabor

Is there a way to definitively know what (and whether any) character is
about to be plunked into a textarea based on keyboard input (from
keydown, keypress, keyup, or other events)?

Hint: this is a trick question.

But you can assume that the textarea has focus, and the focus isn't
changed (no alt+tab type of situations),
and that this is not a question about the clipboard (so we're not
worrying about ctrl+v, delete, backspace, and friends),
and that the entire chain of events is delivered (unlike printScreen or
ctrl+tab and friends).

Furthermore, "plunked into" means that textarea.value will change
(assuming there is no selection). That is to say, I'm really not
concerned with whether the user will see the character well rendered or
whether it's a tab character or a newline or something the rendering
engine doesn't know about.

To be concrete with an example, ctrl+a => "", since it's not a printing
character, and shift+a => "A", and if my keyboard maps ctrl+alt+o to
ó, then ctrl+alt+o => "ó".

Csaba Gabor from Vienna
 
T

Thomas 'PointedEars' Lahn

Csaba said:
Is there a way to definitively know what (and whether any) character is
about to be plunked into a textarea based on keyboard input (from
keydown, keypress, keyup, or other events)?

No. But you can check it afterwards.
Hint: this is a trick question.

How boring.


PointedEars
 

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

Forum statistics

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

Latest Threads

Top