+ Start a Discussion

Enter Key search method not firing

We have a search field that will render results on two actions: clicking a 'Search' button and hitting the 'Enter' key. At present, we can only get results when the button is pressed. When the 'Enter' key is hit, nothing fires (no activity seen via console log on Inspect)

The following shows code in the controller

KeyPresssearch: function(component, event, helper) {
    if (event.which == 13) {
      this.search(component, event, helper);


search: function(component, event, helper) {
    component.set("v.pageNumber", 1);
      var showMembersOnly = component.get("v.showMembersOnly");
      var AccountViewComponent;
      if (showMembersOnly){
      AccountViewComponent = component.find("memberView");
      } else {
      AccountViewComponent = component.find("allView");

What do you recommend I check to troubleshoot this?

Suraj Tripathi 47Suraj Tripathi 47

Hi DML2020,


var isEnterKey = event.keyCode === 13;
     //your code/method will be here

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Suraj Tripathi