PDA

View Full Version : Key.getCode() conversion



Skribble
January 30th, 2009, 04:27 AM
[SOLVED] - Thanks Senocular!

EXPLANATION:

So I've set up some custom controls in my movie that the user can choose, and for the most part they all work fine; you click a control, press a key to bind to it and the key you chose comes up next to the control.

The only problem is my dynamic text boxes display the CODE of the key, not the key itself, which is what I wanted. I didn't want to have to go through and make an if statement for every single possible character on the keyboard if I didn't have to, so I thought i would ask here first.

QUESTION:

Is there any way to convert the value from Key.getCode() in to the actual key that was pressed without creating a custom if statement for the key?

glosrfc
January 30th, 2009, 04:41 AM
Key.getAscii()

Skribble
January 30th, 2009, 01:01 PM
I tried that beforehand and all it does is return the numbered ASCII value of the key, instead of the KEYCODE of the key.

I want to get the actual KEY of the KEYCODE. SO for instance, when I push D to set keyVar as the corresponding KEYCODE, 68, I want to be able to then take that keyVar of 68 and convert it to "D".

>Input key
>Return Keycode
>Convert Keycode to Key Symbol


Cheers

senocular
January 30th, 2009, 01:02 PM
String.fromCharCode()

Skribble
January 30th, 2009, 11:55 PM
Now I have a working custom control feature!

:D
Thanks a bunch, Senocular!

glosrfc
February 1st, 2009, 08:14 PM
I guess I shouldn't rush to answer questions when I'm:
a) drunk
b) tired
c) hungry
d) dying to take a pee
e) all of the above!