Changing Keyboard Input language in Java

2019-07-26 08:17发布

Is there a way to set/change the keyboard input language in Java (eg from English to German)?

Example Use Case: Script to be used for playback is recorded (typed in) on a German keyboard. The automated playback is done on a English keyboard...fails if keyboard is not set to German automatically before script is run.

2条回答
混吃等死
2楼-- · 2019-07-26 09:04

The keyboard input map is managed entirely by the operating system on every platform that I'm familiar with. Java provides no APIs for manipulating this in a cross-platform manner. I would investigate native APIs that you could manipulate via JNA, or even (if you're feeling dirty) shelling out to call some platform-specific command which does what you need.

You're not going to find a solution within the JDK standard lib.

查看更多
Viruses.
3楼-- · 2019-07-26 09:04

In java, you can use the InputContext class. See its API or do google search on InputContext.

查看更多
登录 后发表回答