本文介绍了如何找出语言的字符pressed关键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不能使用CHAR code,或KeyboardEvent的关键code,找出字符pressed,因为即使我改变键盘布局,字符code和关键code都不会改变(如果PSS相同的密钥$ P $)。

I can't use charCode, or keyCode in KeyboardEvent to find out the character pressed, because even if I change the keyboard layout, charCode and keyCode are not change (if press the same key).

那么,如何找到presssed字符,下面以当前的键盘布局?

So, how to find the presssed character, following to the current keyboard layout?

我已经找到这个问题,但什么文件说:

I already found this question, but what the document said:

该字符code属性是数字  在当前的那个键的值  字符集(默认字符  设置为UTF-8,它支持ASCII)。

是不正确的。

编辑:我使用的Flex 4

I am using Flex 4.

推荐答案

我找到了解决办法。

我们可以监听TextEvent,并将。此事件不仅分派到文本组件,而且还实现UIComponent中的所有重点部分。

We can listen for TextEvent. This event not only dispatches to text components, but also all focused components that implement UIComponent.

例如:

package champjss
{
    import flash.events.TextEvent;
    import mx.core.UIComponent;

    public class EditorComponent extends UIComponent
    {
        public function EditorComponent()
        {
            super();

            addEventListener(TextEvent.TEXT_INPUT, handleTextEvent);
            setFocus();
        }

        protected function handleTextEvent(event:TextEvent):void
        {
            // This text the text that user types,
            // following to current keyboard layout ;)

            trace(event.text);
        }
    }
}

这篇关于如何找出语言的字符pressed关键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 22:06