java – KeyEvent. Getkeytext() returns special characters (such as’ vk_enter ‘) in OSX, but there is no solution on Windows XP?

I'm using keyevents and

KeyEvent.getKeyText(KeyEvent.VK_...)

To get the text corresponding to keyevent

In OSX (lion), when I request the text of a special key, such as tab or enter (keyevent. Vk_enter), I get the corresponding symbol (for example, for enter, I get a curved arrow) The same content in Windows XP gave me a key name (such as "enter") instead of a symbol

Is there a solution to get special characters in XP?

Solution

Mac has different implementations:

In this case, you can use the constant VK of the key_ Enter, for example

if (evt.getKeyCode() == KeyEvent.VK_DOWN || evt.getKeyCode() == KeyEvent.VK_KP_DOWN) {}

Alternatively, you can use map to map keys to their string names

map.put(KeyEvent.VK_ENTER,'\u21b5'); \\ ↵
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>