TextField key press listener not called

Hi guys,

I am creating a grid with textfields where I want my data to be modifiable. It works when I call this code on a Textfield outside of the grid, but not there. I think I have to use a binder but I am struggling to understand how it should work here…

Can anyone help? :slight_smile:

here is my code:

for (Week w : weekRepository.findAll()) {

            Grid.Column<EmployeeProject> gridColumn = grid.addComponentColumn(employeeProject -> {
                TextField amountTime = new TextField();
                //Code never called
                amountTime.addKeyPressListener(Key.ENTER, keyPressEvent -> {
                    employeeProject.setAmountTimeEmployeeOnProject(employeeProject.getProject(), w, Integer.parseInt(amountTime.getValue()));

               return amountTime;

            gridColumn.setHeader(w.getWeekNumber() + " / " + w.getYear());


Two things to make your code work:

  1. replace addKeyDownListener() with addKeyPressListener()
  2. in the key press listner, refresh the grid’s dataprovider by calling grid.getDataProvider().refreshAll();

Instead of key listeners, you might also want to consider using addValueChangeListener() in combination with something like textField.setValueChangeMode(ValueChangeMode.LAZY) as these might be better suited for your purpose.