641
Views
5
Comments
Solved
Hide mobile keyboard
Question

When press the "enter"-button on a mobile device I want to trigger an search action and close the keyboard. I get the '$ is not defined' error. My javascript knowledge is letting me down today. Can someone help me?


2017-07-05 22-17-18
Henrique Batista
Staff
Solution

Did you removed the focus from the input? or focus other element?

Something like:

document.getElementById($parameters.MyInput).blur();

Alternatively you can find the Keyboard plugin on the community that allows you to close the keyboard programatically.

Cheers

2017-07-05 22-17-18
Henrique Batista
Staff

Hey Martin,

That error means that you're trying to use jQuery without requiring the jQuery lib, so $ is not defined.

You much likely want something like this:


document.addEventListener('keypress', function myFunc(e){
    if(e.which == 13) {
        $actions.MYACTION();
        document.removeEventListener('keypress', myFunc);
    }
});


Let me know if it worked.

Cheers


EDIT: You probably don't want to remove the Listener there, maybe on blur you should remove the listener

2019-04-02 11-48-16
Martin Rozeboom

Henrique Batista wrote:

Hey Martin,

That error means that you're trying to use jQuery without requiring the jQuery lib, so $ is not defined.

You much likely want something like this:


document.addEventListener('keypress', function myFunc(e){
    if(e.which == 13) {
        $actions.MYACTION();
        document.removeEventListener('keypress', myFunc);
    }
});


Let me know if it worked.

Cheers


EDIT: You probably don't want to remove the Listener there, maybe on blur you should remove the listener

The action does work, but the keyboard won't close. 


2017-07-05 22-17-18
Henrique Batista
Staff
Solution

Did you removed the focus from the input? or focus other element?

Something like:

document.getElementById($parameters.MyInput).blur();

Alternatively you can find the Keyboard plugin on the community that allows you to close the keyboard programatically.

Cheers

2019-04-02 11-48-16
Martin Rozeboom

Thaks for your help! It works fine now!

2026-01-19 13-02-40
Matheus Fonseca

Hello guys, i found a good solution for this problem and i put on this topic:

https://www.outsystems.com/forums/discussion/49343/close-iphone-ipad-keyboard-automatically-when-closing-modal/


See ya! 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.