×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: Richard McDonald
Added: May 8, 2014 4:27 AM
Views: 161
Listen for enter key event on a JavaFX TextField. Obviously adaptable to any key.
  1. textField.setOnKeyPressed(new EventHandler<KeyEvent>() {
  2.  
  3.     @Override
  4.     public void handle(KeyEvent event) {
  5.         if(event.getCode().equals(KeyCode.ENTER)) {
  6.              // do something
  7.         }
  8.     }
  9. });