I wanted to have an ion-input that will be focused and the keyboard should not appear. Is there any way or is it possible? Thank you!
Asked
Active
Viewed 5,398 times
2 Answers
3
yes, install this plugin -> https://ionicframework.com/docs/native/keyboard/
html
<ion-input type="text" [(ngModel)]="message" (ionFocus)="keyboard_show()" #input ></ion-input>
ts
import {
Keyboard
} from '@ionic-native/keyboard';
constructor(private keyboard: Keyboard, private ) {
}
keyboard_show(){
this.keyboard.close();
}

Kevin Dias
- 1,043
- 10
- 28
-
Should the function keyboard_show() inside the constructor? – Ace Aug 20 '18 at 10:39
-
put it outisde the constructor – Kevin Dias Aug 20 '18 at 11:05
-
It gives error : `'Keyboard' refers to a value, but is being used as a type here. Did you mean 'typeof Keyboard'?` – Mitesh Shah Jul 20 '20 at 07:38
2
I tried Kevin's answer and got the same 'Keyboard' refers to a value, but is being used as a type here. Did you mean 'typeof Keyboard'?
issue that Mitesh got.
I resolved this with:
import { Keyboard } from '@ionic-native/keyboard/ngx'
@Component({
selector: 'app-upload-root',
templateUrl: 'upload-root.page.html',
styleUrls: ['upload-root.page.scss'],
providers: [Keyboard]
})
constructor(private keyboard: Keyboard)
this.keyboard.hide();
Not sure how or why this was needed, but it works for me.

Liam Ferris
- 1,786
- 2
- 18
- 38
-
175% of the time when this error is encountered adding ngx to import statement fixes the issues. – Aug 25 '21 at 19:19