views:

33

answers:

0

I would like to store keys pressed when I listen out for the keyDown on the stage. I can add the listener fine, but I'm not getting the character I want out of the event to store it into a string.

This is what I have so far:

    private var _addToString:String = "";
    public function Hotwire()
    {
        this.addEventListener(KeyboardEvent.KEY_DOWN, keydownEventHandler); 
    }

    private function keydownEventHandler(ev:KeyboardEvent):void
    {
        trace("Key pressed: " + ev.charCode );

        addToString(ev.charCode);


    }

    private function addToString(value:uint):String
    {
        trace(_addToString);
        return _addToString += String.fromCharCode(value);
    }

Every key I press its returns '0'. How do I convert the chatCode to a real alphanumeric character I can read later?

Thanks in advance