How to capture the Enter keypress and click?

I had a user input for user to input keyword for searching. When they click the search button, it works properly when the user press enter, but there is no response when the user click the Enter button.
Any help would be greatly appreciated!
Here is my code.

import { local } from 'wix-storage';
import wixLocation from 'wix-location';
function runSearch(){
 let word = $w("#searchBar").value;
 local.setItem("searchWord", word);
 wixLocation.to(`/resultspage`);
}
$w.onReady(function () {
 $w("#searchBar").onKeyPress( (event) => {
 if(event.key === "Enter"){
  runSearch();
  }
 })
}); 
export function vectorImage1_click(event) { 
 runSearch();
}

So you have simply just copied and pasted the code from this previous forum post here.
https://www.wix.com/corvid/forum/community-discussion/how-to-capture-enter-key-press

The original posters code was including a search button, whereas J.D. example contained a vector image that was being used as a replacement for the button instead.

For this export function line to work, you need to have added the onClick event handler function through the properties panel for it.
https://support.wix.com/en/article/corvid-working-with-the-properties-panel