View Full Version : How to get actual keycode value?
dbassett74
30 Sep 2009, 12:12 PM
How do you get the actual key value from a keydown event?
mrsunshine
30 Sep 2009, 1:16 PM
afaik its part of the Event Object which is part of the arguments
dbassett74
30 Sep 2009, 2:25 PM
But I don't think it translates it for you, for example. When you press the letter "B", does it tell you it was "B"? I don't think it does. From all that I can tell, it only returns the ASCII code representing the letter "B". Unless I'm missing something...:-/
karieanis
30 Sep 2009, 4:08 PM
Ext.EventObject.getKey returns the normalised code for the keypress. There are keycode constants in the EventObject prototype which you can use to see if a specific key has been pressed.
eg.
if(e.getKey() === e.BACKSPACE)
{
.. backspace has been pressed!
}
else if(e.getKey() === e.ESC)
....
I'm not sure if there is a list of constant names in the API docs anywhere... you can find them in the source code if you need them.
dbassett74
30 Sep 2009, 7:10 PM
I know about that, but that won't work as I need to simply grab EVERY key the user enters, but the actual key, not the keyCode. I need to add the keys the user entered into a string variable. This can't be too hard, can it??
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.