Java Keybinding Plus Key

后端 未结 3 798
情歌与酒
情歌与酒 2020-12-16 22:37

I was trying to create shortcuts for zooming in and out in an image editing application I\'m creating and I noticed something strange. To bind the combination of ctrl

3条回答
  •  攒了一身酷
    2020-12-16 23:02

    For numeric keypad plus try KeyEvent.VK_ADD:

    getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ADD,
                    KeyEvent.CTRL_DOWN_MASK), "plus");
    

    For plus on main keyboard (US keyboard layout) use:

    getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK),"plus"); 
    

    For non US keyboard use VK_PLUS. See bugs 4262044 and 6942481 for some clarifications.

提交回复
热议问题