# Help with enter onkeypress pls

**URL:** <https://forum.wixstudio.com/t/help-with-enter-onkeypress-pls/51693>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [August 20, 2023, 9:17am UTC](https://forum.wixstudio.com/t/help-with-enter-onkeypress-pls/51693 "2023-08-20T09:17:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ismayrash](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ismayrash/32/8483_2.png) [@ismayrash](https://forum.wixstudio.com/u/ismayrash)\
**Post date:** [August 20, 2023, 9:17am UTC](https://forum.wixstudio.com/t/help-with-enter-onkeypress-pls/51693/1 "2023-08-20T09:17:28Z")

</div>

```plaintext

$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

---

<div class="post-metadata">

**Author:** ![thomasj](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/thomasj/32/30791_2.png) [@thomasj](https://forum.wixstudio.com/u/thomasj)\
**Post date:** [August 22, 2023, 6:25pm UTC](https://forum.wixstudio.com/t/help-with-enter-onkeypress-pls/51693/2 "2023-08-22T18:25:49Z")

</div>

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](https://www.wix.com/velo/reference/$w/textinput/onkeypress) to run the query when you hit the enter key.

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

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

```
