Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert CharCode to Char?

What I need

ok I googled this and there are many tutorials on how to get the charCode from the character but I cant seem to find out how to get the character from the charcode.

Basically I am I am listening for the KeyDown event on a TextInput.

I prevent the char from being typed via event.preventDefault();

Later I need to add the text-char to the TextInput.

I can get the charCode via event.charCode so if I can turn that into a string I can save it for later user.

Why I need it

Basically I am making a TextInput, that that I can set to display default text in it. When A user types into it, I want to remove the default text first then add the user typed text.

Currently I am either removing it all, or ending up with both.

like image 571
JD Isaacks Avatar asked Feb 02 '10 21:02

JD Isaacks


1 Answers

It's simple:

var yourNewChar:String = String.fromCharCode(event.charCode);
like image 103
Robert Bak Avatar answered Sep 21 '22 04:09

Robert Bak