0

I am using Ionic 3 and Angular 5. I have a text-area with Auto focus. problem is, I do not want to show keyboard in auto focus. How can I hide keyboard in Auto focus. Here is my code.

 setTimeout(() => {
  this.myInput.setFocus();
},1000);

This code is for Auto focus.

<ion-textarea style="color:red; opacity: 0;" #input id="myInput" rows="1" maxLength="500"  [(ngModel)]="details" (ionChange)="Scan($event)" ></ion-textarea>

This is HTML code please help me out. Thanks

1 Answers1

0

You can use this code for hiding keyboard

import { Keyboard } from '@ionic-native/keyboard';

constructor(private keyboard: Keyboard) { }

...

this.keyboard.show();

this.keyboard.close();
Paresh Gami
  • 4,777
  • 5
  • 23
  • 41
  • 1
    Unfortunately when running `this.keyboard.close()` it loses focus of the input field – thefoyer Jul 27 '18 at 04:15
  • Right.. But then the keyboard pops up. There is no way to focus an input while keeping the keyboard closed? This is what the OP describes and it's also the issue I'm trying to solve as well. >I do not want to show keyboard in auto focus – thefoyer Jul 27 '18 at 14:42
  • @thefoyer Did you find any solution to hide the keyword while focusing the input field? – Mitesh Shah Jul 20 '20 at 07:38