0

I have two key binds on my code:

private void enterBind(){

    String key = "ENTER";
    KeyStroke keyStroke = KeyStroke.getKeyStroke(key);

    //code  
}

private void altSBind(){

    String key = "VK_S";
    KeyStroke keyStroke = KeyStroke.getKeyStroke(key);

    //code
}

The enter bind is fully working, but the "Alt S" bind is not, I tryed to research what should I insert in the place of "VK_S" but until I got no sucess on it. Is this simple to solve?

Victor Oliveira
  • 3,293
  • 7
  • 47
  • 77

1 Answers1

1
"alt shift X" => getKeyStroke(KeyEvent.VK_X, InputEvent.ALT_MASK | InputEvent.SHIFT_MASK);
"alt shift released X" => getKeyStroke(KeyEvent.VK_X, InputEvent.ALT_MASK | InputEvent.SHIFT_MASK, true);

This might help.

Sagar Tandel
  • 299
  • 1
  • 3
  • 10
  • Just to clearfy, I was wanting just to hit Alt+S and the code up is for Alt+Shift+S, which means if you remove the InputEvent.SHIFT_MASK it will work the way I want. +1 for the awesome answer, ty – Victor Oliveira Sep 13 '13 at 11:54