How hide when input is focused or disable keyboard completely?

Hi guys,

Found similar posts but nothing seems to address my situation. Tried numerous approaches and close to giving up.

Am writing app for android 4,1.1 barcode scanner Motorola MC67.

It has physical keyboard so if I could disable the soft input keyboard (soft keyboard) popping up at all when in my app that would be less preferred but acceptable solution. If not this is what I’m trying to do:

I have two input in a view. If user taps first input soft keyboard shows which is fine. When they’re done they press the ENTER key (keycode 13). The reason we look for keycode 13 is b/c barcode scanner (keyboard wedge mode) is configured to add an ENTER suffix at the end of a scan. This way user can enter text using soft keyboard and press ENTER on physical keyboard OR simply scan a barcode.

For ex. to enter ‘abc’ and go to next field user can use soft keyboard to enter ‘abc’ then press ENTER key to go to next field. Or user can scan barcode ‘abc’ which in keyboard wedge mode is like user typed in ‘abc’ and pressed ENTER.

The issue is when user types ‘abc’ then presses ENTER I put focus on the next input but can’t close the keyboard either using ng-blur on first input or ng-focus on second input. I know normally you would want the soft keyboard to show when an input has focus but in this case the unit has hard keyboard and user may also want to scan barcode so it’s preferred to show more of the view vs showing soft keyboard.

Here are some code snippets from my project. I also tried adding a 1 sec delay using $timeout (not shown in code below) before closing keyboard in case it was a timing issue i.e. I call close before it’s actually shown. Didn’t work.

Am new to ionic but loving it and hope to use it in my projects (faster then xamarin). Appreciate any help.

        <label class="item item-input">
            <input type="text" placeholder="Destination address" autofocus
             ng-model="myInput.destinationAddress" focus-on-enter="itemBarcode"
             ng-blur="cordova.plugins.Keyboard.close();" >
             
        </label>

        <label class="item item-input">
            <input type="text" placeholder="Item barcode" ng-model="myInput.itemBarcode"
            id="itemBarcode" click-on-enter="saveButton"
            ng-focus="cordova.plugins.Keyboard.close();">
            
        </label>

// ....
 .directive("focusOnEnter", function () {
    return {
        restrict: "A",
        require: 'ngModel',
        link: function (scope, element, attrs, ctrl) {
            element.bind("keyup", function (ev) {
                if (ev.keyCode == 13) {
                    ctrl.$commitViewValue();
                    scope.$apply(ctrl.$setTouched);
					
                    document.getElementById(attrs.focusOnEnter).focus();
                }
            });

        }
    };
})
1 Like

hi,

did you found the solution or workaround ?
same here. ionic 3.9.2

norbert

Hi there, did you manage to find a solution? I was about to do the same issue in my current app. I search google and didn’t find any solution. Hopefully you found out the solution and it is a big big help for me and to every one here! Thanks!

did you manage any solution?