This content has been marked as final. Show 1 reply
your issue IMO is keyEvent.getCode() What you are returning is a KeyCode, not what key it is. If you have issues, try using a System.out.println();
What I use for my Mouse and Key events is
so just switch from MouseEvent to KeyEvent and it should all work.
event.getEventType() == MouseEvent.MOUSE_DRAGGED
Lets look at the API http://docs.oracle.com/javafx/2/api/javafx/scene/input/KeyEvent.html
Your KeyEvents are
getCode public final KeyCode getCode() The key code associated with the key in this key pressed or key released event. For key typed events, code is always KeyCode.UNDEFINED. Returns: The key code associated with the key in this event, KeyCode.UNDEFINED for key typed event
The important getEventType() is inherited from Event http://docs.oracle.com/javafx/2/api/javafx/event/Event.html#getEventType()
Field Summary Fields Modifier and Type Field and Description static EventType<KeyEvent> ANY Common supertype for all key event types. static java.lang.String CHAR_UNDEFINED KEY_PRESSED and KEY_RELEASED events which do not map to a valid Unicode character use this for the keyChar value. static EventType<KeyEvent> KEY_PRESSED This event occurs when a key has been pressed. static EventType<KeyEvent> KEY_RELEASED This event occurs when a key has been released. static EventType<KeyEvent> KEY_TYPED This event occurs when a key has been typed (pressed and released).
It can also be found in the KeyChar API right under the "Method Summary."
getEventType public EventType<? extends Event> getEventType() Gets the event type of this event. Objects of the same Event class can have different event types. These event types further specify what kind of event occurred. Returns: the event type