KeyStroke space = KeyStroke.getKeyStroke('Z'); KeyStroke fromKeyEvent = KeyStroke.getKeyStrokeForEvent(keyEvent);