Disable the keyboard "return" button in ionic 2

Hi together,

How to disable the keyboard “return” button in ionic 2?

Thanks

This is a harder question than it probably seems. Does it have to work both on browser and device? Everywhere or only when specific components are focused?

My ionic app will be deployed only on device. I would appreciate it, if I could have an option to disable the “return” button only when specific components are focused.

Regards

Do you want to “disable” (nothing happens when used) or “remove” (is not displayed) it?

Disable (nothing happens when used)

Often I’ve found that when I thought I wanted to do this, I was actually failing to add type="button" to my non-submit buttons that happened to be inside forms.

If that’s not the case, I would look into binding (keyup.enter)="swallow()" and having swallow() return false.

1 Like

Thanks! I will try it.

Hey! I have a case for this - I want to disable (grey out) the search button until it’s relevant. Just like in iOS contacts app - searching your contacts, if the search field is empty the search key on the keyboard is greyed out. Once you enter a character the button is enabled.

Does anyone know how to achieve this. Ionic 3 and Ionic native keyboard