4 Replies Latest reply on May 14, 2012 2:03 PM by 905489

    Enter = Tab


      Can anybody help with this: I want the enter key on the keyboard to behave the same as the tab key, in JavaFX 2.1?


      Thank you.
        • 1. Re: Enter = Tab
          Where is the text being entered into? The only experience I have had with entering text in JFX was when i created my own text box that captured all the keyEvents and decided what to do with each pressed key. For example I would filter everythign out except the alpha keys, backspace, and enter. You should be able to capture the Enter KeyCode and decide how to change your text field to. But then again thats if you are doing the capturing of the KeyEvent yourself.... you might be using a Class that abstracts that out for you so that you do not need to worry (control) over it.
          • 2. Re: Enter = Tab
            I am entering it into a TextField. When I press enter on the TextField it must react the sam way as a Enter key.
            • 3. Re: Enter = Tab
              Hi. How about this?
                final  TextField txt = new TextField();
                      txt.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
                          public void handle(KeyEvent event) {
                            //  if (event.getCode() == KeyCode.ENTER ) {txt.appendText("\t");}  //looks like it is not working. 
                             if (event.getCode() == KeyCode.ENTER ) {txt.appendText("   ");}  
              Edited by: shakir.gusaroff on May 2, 2012 11:29 AM
              • 4. Re: Enter = Tab
                Thank you. I will try that