inputText value is not updating in a repeater object

Im trying to update a field when a user press ‘Enter’ in the input field. I wrote this:

$w(" #userInput “).onKeyPress((event) => { if (event.key === “Enter”) { console.log(event.context); console.log($w(” #userInput ").value); } });

this works fine if both elements are in a page, but if I drag them to a container in a repeater object, then the value is not giving me the current value (but rather the previous value/empty value)

i would expect it to print the string that i put in the input field as I expected it to do.
Any ideas why this is happening and how to make this work?

Refael,

Updating an element in a row of a repeater requires using the at() function that creates a context-sensitive object ($item) that is used in place of the normal $w reference.

$w("#userInput").onKeyPress((event) => {     
    if (event.key === "Enter") { 
        let $item = $w.at(event.context);                                           
        console.log($item("#userInput").value);     
    } 
});