How to hide keyboard when backspace is hit at empty ionSearch?

Hi Guys, Does anyone know how to hide the keyboard when backspace is hit at empty ion-search field?
I have tried

(keypress)=“onType($event.keyCode)” in the tag

then in the .ts

if (keyCode == 8){
this.keyboard.close();
}

but didnt work… I would really appreciate if anyone knows how to do this.

Here’s a video to make you know what exactly I mean…