Disabling OS keys

Started by Rene, September 13, 2009, 12:43:10

Previous topic - Next topic

Rene

Does anybody know if it's possible to make the OS not process events like the windows key, or the ctrl+esc combination for example?

It would also be great if it's possible to disable only a few of them, as alt+tab and alt+f4 are useful to keep.

Thanks in advance

Rene
When I am king, they shall not have bread and shelter only, but also teachings out of books, for a full belly is little worth where the mind is starved - Mark Twain

broumbroum

You can try to catch them in your app, then the dispatcher will let them away without sending back to the system events ::).

Rene

Can you please be a bit more specific? Do you mean I should use a JFrame, and add a KeyListener to it to catch the events?
When I am king, they shall not have bread and shelter only, but also teachings out of books, for a full belly is little worth where the mind is starved - Mark Twain

broumbroum

Not exactly : just add a link (once) to the keyboard manager to catch the specific events in a static area
KeyboardFocusManager.getDefault...().addKeyEventDispatcher(new KeyEventDispatcher() {
public boolean distpatchKeyEvent(KeyEvent e)  {
        // check the keycode (may ID pressed or released or both...)
        if(e.getKeyCode() == KeyEvent.VK_WINDOWS || andOTHERKEYS...) // I don't know the correct identifier though
                   return true; // THIS LINE OVERRIDES ALL SUBSEQUENT DISPATCHERS.
else return false;
}
});

That SHOULD be OK. =)

Rene

Nope, I'm afraid it doesn't work. The KeyEventDispatcher doesn't receive any key events at all! Any idea what might be wrong?
When I am king, they shall not have bread and shelter only, but also teachings out of books, for a full belly is little worth where the mind is starved - Mark Twain