Victor Oliveira
Victor Oliveira

Reputation: 3713

Set bind with Alt key - Java

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?

Upvotes: 0

Views: 422

Answers (1)

Sagar Tandel
Sagar Tandel

Reputation: 299

"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.

Upvotes: 1

Related Questions