PDA

View Full Version : Detecting character key strokes.



jorgedbucaran
September 30th, 2007, 02:48 AM
?

ptobias
October 1st, 2007, 01:20 AM
I'm not sure I understand your question. Are you trying to capture what character key the user pressed?

If so, try this:

stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);

function keyDownHandler(event:KeyboardEvent):void
{
trace("Key Pressed: " + String.fromCharCode(event.charCode) + " (Is Shift Down: " + event.shiftKey + ")");
}

ptobias
October 1st, 2007, 01:34 AM
Test it outside the Flash IDE on a browser. Some lowercase characters are keyboard shortcuts for items on the Tools panel in Flash. For example, when you test the movie inside Flash and press "z" the zoom tool (magnify glass) gets focus.

ptobias
October 1st, 2007, 12:38 PM
you're welcome.