ComboBox auto-select with enter key

Hello,

I’m trying to get a combobox to behave exactly as it does on the demo sample.
What this means is that when the user enters a value that matches exactly the caption of one item in the filtering list, hitting enter on the keyboard selects the item (and then the ValueChangeListener can do its thing). If it’s not an exact match but there is only one option left in the filtering list, it selects the item too.

I can’t get my combobox to work that way, the filtering works fine but when I hit enter nothing happens, I have to select the item in the filtering list with the mouse or use keyboard arrow keys and then hit enter.
I tried to use a ShortcutListener but I don’t know how to grab the raw value typed in the combobox…

Here is what my code looks like:

        ComboBox prompt = new ComboBox();
        prompt.setImmediate(true);
        prompt.setInputPrompt("Table");
        prompt.setWidth("250");

        BeanContainer<String, Table> tables = new BeanContainer<>(Table.class);
        tables.setBeanIdProperty("name");
        for (Table t : METADATA.getTable()) {
            tables.addBean(t);
        }
        prompt.setContainerDataSource(tables);
        
        prompt.setItemCaptionPropertyId("name");
        prompt.setItemCaptionMode(ItemCaptionMode.PROPERTY);
        prompt.setFilteringMode(FilteringMode.CONTAINS);
        prompt.setNullSelectionAllowed(false);

        prompt.addValueChangeListener(new ValueChangeListener() {
            @Override
            public void valueChange(Property.ValueChangeEvent event) {
                  //stuff
            }

        });

Any ideas?
Thanks

As per checking http://demo.vaadin.com/sampler/#ui/data-input/multiple-value/combo-box, you can view its code by clicking i on the top then select the source tab. Check the setNewItemHandler method used in the combobox. That should provide the behaviour you want.

Thank you very much!
I got what I wanted from the setNewItemHandler method.