Disable Firefox OS keyboard autohiding when touching outside the keyboard
Asked Answered
H

1

11

When I tap an input field in Firefox OS, the on screen keyboard comes up. I am developing a messenger app and have a toolbar that borders the on-screen keyboard with a "Send" button.

When I tap the send button, the keyboard automatically closes which I do not want (the user may have to enter more messages).

How do I prevent the keyboard from closing when an outside touch is detected? I have searched all over the net and cannot find an answer (though it seems the Marketplace apps have this behaviour).

Homocyclic answered 10/11, 2014 at 9:40 Comment(3)
Is this a duplicate? How to show keyboard programmatically in Firefox OS?Stipitate
Already looked at that. "I fixed it by setting the focus onto the textbox first when I click the add button then do the actual adding stuff." is not very clear, and also doesn't work.Homocyclic
even when you force focus on the text input after "send" is clicked? because that's what you're describing as what should happen when you say "the user may have to enter more messages". They can't enter messages unless you've moved focus back to the text input after the send button gains focus, so the keyboard should come right back once the text input gets focus.Epencephalon
F
8

you can try to create a hidden input which receives the focus once your visible input field loses it.

var input = document.getElementById("text");
var trap = document.getElementById("trap");
input.addEventListener("blur", function() {
  trap.focus();
}, false);
#trap {
    position: absolute;
    width: 1px;
    left: -10px;
}
<input type="text" id="text" />
<input type="text" id="trap" />
Faris answered 18/11, 2014 at 21:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.