I’m trying to implement a JPopupMenu over a text editor component. It should be activated on CTRL+m. Can I do that inside
@Override
public void keyPressed(KeyEvent arg0) {
}
and if yes, how? Because if I try
if(arg0.isControlDown()&&arg0.getKeyChar()=='m')
it doesn’t work.
At first I thought it was something to do with CTRL+M being the same thing as a carriage-return/line feed, but that wasn’t true. Try:
I couldn’t get it to work using chars with e.getKeyChar() either, but the getKeyCode() works for me. Great, it works. But I’m the type that has to know why. So I found this: