How to detect search button when click on keyboard


#1

hi guys, I am trying to add a search page… I have included a search button and when clicked, a modal page opens with ion-search in the header.

When click on the input bar, keyboard obviously appears and when the user types and presses search button on the keyboard, how to bind that key… so that I return the typed search value.

this is what I have done

.html: (SearchModalPage)

 <ion-header>
     <ion-toolbar no-border-top color="androidprimary">
        <ion-searchbar
             [showCancelButton]="shouldShowCancel"
             (ionInput)="getItems($event)"
             (ionCancel)="onCancel($event)">
        </ion-searchbar>
      </ion-toolbar>

    </ion-header>
 <ion-content padding>
 </ion-content>

And btw, I am trying something similar to youtube application searchbar function


#2

Checkout this: Getting the Keyboard GO button to act like the app Submit was clicked

It’s for Ionic 2, but maybe the same goes for Ionic 2 (Most likely). In short: Wrap the searchbar in a form with a submit event, add a button with type submit.