As far as I know, you can't use the KeyboardEvent class for this purpose 
because KeyboardEvent.charCode is designed to return the same value no matter 
which language you use for input. What you need to do is actually capture the 
value input into your text field and use String.charCodeAt() on that value. 
Here's a blog post I came across with a working example and the source code 
behind it:

http://blog.flexexamples.com/2007/07/21/finding-out-a-characters-unicode-character-code/

It's a flex example, but the core ActionScript code would be pretty much the 
same in Flash. Just use charCodeAt() on the value you grab from your custom 
textfield. When I switch my input mode to Russian for the sample swf on that 
page, I get charcode 1092 for russian key "ф" and charcode 97 for English key 
"a".

HTH,

Francis Cheng | Sr. Technical Writer | Adobe Systems Incorporated

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dani Bacon
Sent: Wednesday, December 12, 2007 12:02 PM
To: Flash Coders List
Subject: Re: [Flashcoders] as3 + non english input charCode ?

kerry hi, and thx

i think i didnt explain myself well.
i am using arial and i am successful in typing into a textfield, but thats
not what i am trying to do.
i am trying to listen to the keyboardevent keyDown and know which character
was typed (in langauge other than english).
for example set up an empty FLA with the following code

stage.addEventListener( KeyboardEvent.KEY_DOWN, test );

function test( evt:KeyboardEvent ):void
{
    trace( String.fromCharCode( evt.charCode ));
}

if i have a russian keyboard layout and i type the russian key "ф" ( "a" key
in english layout ) the prev code still traces "a".
i need somehow to know what russian (or other language) char was typed.
basically i built my own custom textfield that has some special
functionality and it captures the keyboard etc and i am trying to get it to
work also with other languages, but it seems the keyboardevent doesnt let me
know which foreign language char was typed.

anyone ? ideas ?

On Dec 12, 2007 8:08 PM, Kerry Thompson <[EMAIL PROTECTED]> wrote:

> Dani Bacon wrote:
>
> > KeyboardEvent.charCode, as stated in the as3 docs, returns the english
> > keyboard layout char code that was pressed...
> > that is even when i switch my keyboard to a russian layout, i keep
> getting
> > the charCodes as if it was still set to english.
> > so, how do i get the russian char that was typed (or any other language)
> ?
>
> You need to use a Unicode font. If you're on Windows, you probably have
> Arial Unicode MS. Embed the Cyrillic character set, and it should work.
>
> Cordially,
>
> Kerry Thompson
>
>
>
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to