Connecting Tech Pros Worldwide Forums | Help | Site Map

keyboard events and characters

Csaba Gabor
Guest
 
Posts: n/a
#1: May 10 '06
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


Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a
#2: May 19 '06

re: keyboard events and characters


Csaba Gabor wrote:
[color=blue]
> 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)?[/color]

No. But you can check it afterwards.
[color=blue]
> Hint: this is a trick question.[/color]

How boring.


PointedEars
--
Those who desire to give up freedom in order to gain security,
will not have, nor do they deserve, either one.
-- Benjamin Franklin
Closed Thread