Reputation: 211
I have some hardware sending input to my app, either by Bluetooth or wired hardware keyboard. At the moment I have a text field taking the input. I need the field to auto-focus when the screen loads, but without haivng the soft keyboard popup on focus.
I've tried autofocus attribute for HTML, but it messes with the view when I'm using Ionic.
I also tried using an angular directive, to focus after 500ms.
.directive('focus', function($timeout, $parse, $cordovaKeyboard) {
return {
restrict: 'A',
link: function(scope, element, attrs) {
$timeout(function() {
element[0].focus();
}, 500);
}
}
})
Is there a way of focusing without the soft keyboard displaying in both iOS and Android? I need the soft keyboard to popup only when the user clicks on the input field manually.
The other option would be to have a listener for any hardware keyboard inputs - but I can't see any way to do this in Cordova.
Upvotes: 3
Views: 1749
Reputation: 520
The solution for hide/show software keyboard in Ionic framework project is cordova-plugin-ionic-keyboard - see it on GitHub: https://github.com/ionic-team/cordova-plugin-ionic-keyboard
Short info is also in Ionic documentation: https://ionicframework.com/docs/native/keyboard
(Text was updated on 7th Jan 2020, because previously recommended extension ionic-plugin-keyboard is deprecated.)
Upvotes: 1