开发者

How do I remap the NumLock key in Java Swing?

You may have read my earlier question about remapping my keyboard at a low level in Java and I did find a solution - mostly.

To be honest, I oversimplified the problem I was trying to solve. I not only want to match NumericKeypad 1-3 to 7-9 and vice versa, I want to remap the whole numeric keypad. In particular, I need to remap the NumLock key which is part of that keypad. This seems to be intercepted on a System level and I cannot just map it to emit some character.

What I want is that when running my application, th开发者_运维问答e NumLock key does not toggle the system NumLock setting, but instead emits some other key.

Am I beyond the realm of what is possible in Java here? Or is there some way I can dig down to this low level and accomplish this as well.


The solution I came up with won't work for everyone, but it's actually optimal in our use-case:

Use the Windows registry to do the keyboard remapping.

It's permanent, requires no JNI or device-driver writing and in our case we have no worries about messing up the keyboard for other applications. Very simple.

If you need to do this and can get away with this hack, it's the cost-effective solution.


I'm not sure it's what you want, but you might have a look at this game's key-event editor, pictured in a screenshot, shown below and implemented in org.gcs.robot.RCKeys.

How do I remap the NumLock key in Java Swing?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜