Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable the native keyboard on Ionic

Clearly solutions like this do not work as expected on Android 5.1.* (the KB flickers (quickly opens & closes)).

.directive('disableKeyboard', function ($timeout, $window) {
    var linker = function (scope, element, attrs) {

        if (!$window.cordova || !$window.cordova.plugins.Keyboard) {
            return;
        }

        element.bind('focus click',
            function (e) {
                e.preventDefault();
                $timeout($window.cordova.plugins.Keyboard.close, 0);
            }
        );
    };

    return {
        restrict: 'A',
        link: linker,
    }
})

The Ionic forum has not given meaningful solutions. Any suggestions? Please note: I would like to avoid cordova.plugins.Keyboard.close. Thank you.

like image 412
Vidul Avatar asked Oct 11 '25 10:10

Vidul


1 Answers

Add disabled attribute to your input tag, for example

<input type="text" name="lname" disabled>

NOTE: This might change background color of input tag, but you can change that using css.

like image 138
Mudasser Ajaz Avatar answered Oct 13 '25 22:10

Mudasser Ajaz