Search database when enter is pressed

I work in a shop selling esigarettes. We have over 200 different flavors. I’ve put everyone in a database and customers should be able to search for taste. It searches when you press the search button. But I want it to also apply when the customer presses the enter key. I can very little about code and what I have now I have taken from youtube. Can anybody help me? I’m stuck my head in the wall with this problem … This is the code I have now:

import wixData from ‘wix-data’;

export function searchField_click() {
.contains(‘description’, $w(‘#searchInput’).value)
.or(wixData.query(‘allJuiceSmak’).contains(‘title’, $w(‘#searchInput’).value))
.then(res => {
$w(‘#repeater1’).data = res.items;

Check out the API that refers keyboard event here .
Basically you can create an event for enter key press or any other key only while the cursor is located inside a textInput or textBox.

I have been trying for a long time, but I do not get it. can you try to make an example to me? I do not figure out how to choose the enter button

Use this code for example to run the program when enter is clicked:

export function input1_keyPress(event, $w) {
 if(event.key === "Enter"){
        console.log("Enter was pressed!")// insert your code here
1 Like

WOW! It works, thank you so much!!

1 Like

Very helpful, thank you!