Search on Enter

Hey Everyone
I’m new to Wix so bear with me. I’m looking to have a search bar that redirects to another page (I used code queens tutorial which was fantastic). I just want to add the feature that it either searches on pressing the search button or pressing the enter key. Here’s my current code which works but only with the search button. Just wondering what I need to add to it

import {local} from ‘wix-storage’;
import wixLocation from ‘wix-location’;

$w.onReady( function () {
});

export function SearchButton_click() {
let word = $w(“#SearchBar”).value;
local.setItem(“searchWord”, word);
wixLocation.to(/substances);
}

Hi,
Check out the KeyboardEvent API here and add an if statement that checks whether the enter key was pressed.

Good luck :slight_smile: