Is it possible to stop a key from being dispatched? I basically want to disable the number pad from firing its numbers – it should fire a macro instead. The problem is it does both. Here is the code:
@Override
public boolean dispatchKeyEvent(KeyEvent keyEvent) {
//If key has macro assigned then fire that (working fine)
if (keyEvent.getKeyLocation() == KeyEvent.KEY_LOCATION_NUMPAD) {
return true;
}
}
Reading the spec for KeyEventDispatacher, if returning false it says it will pass the event on. It appears to be doing the same for true. Is there a way of stopping it from passing the event on? Or am i doing something stupid?
Thanks,
You should call
consume()on the event to show it has been handled.