Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide The iPad Keyboard By Hitting the Return Key

Is it possible to hide the iPad keyboard after entering a value into an input field on a website by hitting the Return key without forcing the user to use the Hide Keyboard key?

Is there something in HTML or jQuery that I can code into my page to force this behavior?

(P.S. Based of my hours of research online, it seems impossible with the way the iPad currently functions. But I would really appreciate any info!)

like image 434
Alex Avatar asked Jan 26 '11 22:01

Alex


People also ask

How do I hide my keyboard on iPad?

How to hide the keyboard on iPad devices using the Press Key method. This is useful when there are objects behind the keyboard. To automatically close the keyboard on iPad devices, click on the “Hide Keyboard” button (circled below). To hide the keyboard, use the Press Key method with the HIDE_KEYBOARD Key value.

How do I hide my Apple keyboard?

To hide it, slide your finger down from above the text-entry box and the keyboard will start to disappear. Carry on until only the text-entry box is left. To make the keyboard reappear, tap the text-entry box and it will shoot right back up so text can be entered again.

How do you press Return on iPad keyboard?

Hi, Sifgirl - when you are typing on the keyboard on iPad, the "return" key on the right side is the "enter" key. Hope this helps!


2 Answers

You can hide the keyboard by calling the blur handler on the text input:

$("#textField").blur();

where #textField is a selector to select the text input. You need to put this line in the right place, which depends on how the form is coded, and in most cases would be in the form's submit handler.

like image 83
Elias Zamaria Avatar answered Sep 27 '22 19:09

Elias Zamaria


The easiest answer to your question on any input regardless of form submit would be

$('input').keyup(function(event) {
    if (event.which === 13) {
      $(this).blur();
    }
});

Probably a little easier to put in the right place.

Return = Enter key

like image 30
ian_sawyer Avatar answered Sep 27 '22 21:09

ian_sawyer