Help with enter onkeypress pls


$w.onReady(function () {

    $w('#searchButton').onClick(function () {
        // let detal = "detalCode"
        let query = wixData.query('Prospect').contains("detalCode", $w("#searchBar2").value); //limit qoymusam resulta tesir edir     
        // .or(wixData.query("Prospect").eq("ad", $w("#searchBar").value))             

        query.find()
            .then(result => {

                if ($w("#searchBar2").value.length >= 7)
                    $w('#table1').rows = result.items;
                    $w("#countText").text = `ehtiyat hissəsi tapıldı`;
                    $w("#countText").show();
                } else { $w("#countText").text = `ehtiyat hissəsi tapılmadı`; }

                //$w('#table1').rows = result.items
                $w("#clearFilter").show();
            })

    })

    //CLEAR FILTER 🚀
    $w.onReady(() => {

        $w('#clearFilter').onClick(() => {
            $w("#searchBar2").value = undefined;
            $w("#dataset1").setFilter(wixData.filter())
            $w("#clearFilter").hide();
        })
    });

});

add to my #serachButton enter key press pls

Hi,

It seems you are using the value from a TextInput element to search for items in a collection. If this is the case you can use the onKeyPress() event handler to run the query when you hit the enter key.

Here is a example of what this code can look like:

$w.onReady(function () {
    $w("#searchBar2").onKeyPress((event) => {
        if (event.key === "Enter") {
            //Handle "Enter" Button Click
            //Current TextInput value stored in: $w("#searchBar2").value
        }
    });
});