1

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, the 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.

Community
  • 1
  • 1
Steve Cohen
  • 4,679
  • 9
  • 51
  • 89
  • 1
    You're definitely beyond the realm of what is *practical* in Java. Many things are *possible* in Java through JNA or JNI, but it's not really Java doing the work, it's just calling out to native, OS-specific code. – Mark Peters Jun 16 '11 at 01:10
  • I am willing to dig down to the JNA or JNI level if I need to. I have control of the environment and don't have to worry about portability to other OSes. This needs to run on Windows only. But I've never done this before. I know C fairly well. Where would I go to learn more about doing this? – Steve Cohen Jun 16 '11 at 01:14
  • @Steve: With JNA you can perform pretty much any Windows system call (assuming Windows, or *nix system calls otherwise). Unfortunately I don't know the Windows system API well. My Google skills are only as useful as yours. From a Swing perspective, I have nothing to suggest. – Mark Peters Jun 16 '11 at 01:19

2 Answers2

1

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.

image

trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • Not to be confused with Swing [Key Bindings](http://download.oracle.com/javase/tutorial/uiswing/misc/keybinding.html). – trashgod Jun 16 '11 at 02:19
1

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.

Steve Cohen
  • 4,679
  • 9
  • 51
  • 89