Javascript / jQuery Windows 8 On-Screen Keyboard - javascript

I'm trying to build an application where if the user activates a page, a focus event will occur and focus into a text field. I was half-heartedly expecting that when I called .focus() on in the input box, Windows 8 would pop-up the on-screen keyboard. This in not the case.
Does anyone know of a way to get the Windows 8 on-screen keyboard to come up when the text field is focused via javascript.
If the user "taps" into the textfield, the focus event does fire and the keyboard comes up.
I've tried binding to touchstart, 'touchend, click and focus, but all of these do not seem to activate the on-screen keyboard.
This application will run strictly on Windows 8, so there is no need to make it so that other platforms that do not have built-in on-screen keyboards work properly.

You can't. Only user actions can open the on-screen keyboard. This is by design. See here.

Related

Prevent soft keyboard closing on text input blur

I am building a Web chat application (PWA).
I have a chat input, which I would like to keep focus on even when the "send" button is clicked. So I want the keyboard to stay open even when a chat is sent, either by pressing a "send" button, or by clicking on the "send" in the mobile's keyboard itself. This is the behavior you get in messaging apps like Whatsapp, iMessage, etc.
Even though it works on Android as expected, but I can't make it work on iOS Safari / Chrome.
What I have tried so far is as follows:
Bind touchstart / mousedown event, call preventDefault and stopPropagation.
Additionally, I am also doing "preventDefault" on the click event.
How can I achieve this on iOS Safari with vanilla javascript + HTML?

How can I focus on a text input without showing on-screen keyboard

I'm making a chat service, and I want to support mobile devices well.
On a screenshot below, there is an input field. It allows typing text, and to avoid issues like "if the text field is unfocused typing does nothing" it automatically gets focused when clicking outside of it - this does improve the experience on desktop computers. However, on devices with software keyboard, this causes on-screen keyboard to appear on mobile devices which is distracting.
Considering clicking anywhere focuses the text input, is it somehow possible to make on-screen keyboard only appear when the text field is pressed? Or alternatively, somehow detect devices with software keyboard enabled and disable this feature for them. Preferably without explicitly trying to detect mobile devices, touch screen or whatever as there exist touch screen devices with hardware keyboards.
This issue I was able to reproduce in Google Chrome and Opera Mobile on Android, and apparently it happens on iPhones, although I have no device to test it on.
Here is a rather simple example of an issue. If you touch the pink rectangle, it will cause touch keyboard to appear, which I don't want.
<input type=text id=f>
<div style="background: pink; height: 200px; width: 200px" onclick="f.focus()">
The short answer is that this is a built in function and you can't stop it, but there are a couple of options to consider.
1) use the onFocus event to immediately trigger the blur event to hide the keyboard again.
2) set readonly="true" on the element, later remove it and trigger the focus event.
3) create a fake input element with div's and css, when you want to trigger the keyboard focus on a hidden input field and copy out the value of the input on the keyup event as the user types.
Hope these suggestions were helpful to you.
If I got this right, you may also consider to change the logic of focusing the textfield when there is a click "anywhere". On touch-devices the touch events get dispatched first and you can cancel the click-handling (look for preventDefault(), return false; or stopPropagation() which should be called in you touch event handler).
You will need another event listener which handles the touch events outside the textfield, e.g. "touchstart".
If you want to keep the ui effect of a focused textfield, just add a css class "focused" to the textfield by script instead of using textfield:focused{} for your styles.

Input loses focus when keyboard opens in iOS Browsers

Any input that I tap inside of my Swiper-Slide on the page lose focus when they keyboard opens (in Chrome and Safari). Once the keyboard is open, I can click the input and then start typing. I'm not exactly sure what's causing the problem because inputs outside of the slider work like normal.
I have an onFocus function being called by the input that doesn't fire the first time it's clicked even though the keyboard pops up. Is there some Javascript or Jquery way to force the browser to focus an input that works in iOS browsers?

How to handle differences in iOS and Android Keyboard

For HTML/JS in mobile browsers, I'm having an issue where blur events trigger differently in iOS and Android. In iOS, a user can click on "Done" on the native keyboard, which hides the keyboard and causes the focused element to blur.
The same, however, does not happen when a user clicks the back icon in Android to hide the native keyboard; The elements that were previously focused keep their focus.
Is there a way to listen for the keyboard hiding and trigger a blur on the focused element? Or is there a way to force the Android keyboard to display a "done" button? Or is there a generally better solution?
Maybe a solution would be to listen to the keydown event on the input, and check if the keypress is "Enter".
To do that, please refer to this :
Enter key press event in JavaScript

HTML text input - Prevent Windows 8 touch keyboard?

Is there a way to prevent the on-screen keyboard from popping up by default when a HTML text input field gets focus on a windows 8 touch screen pc?
The application in question is a barcode/rfid scanning web application.
It would be preferable if the user could also still pop up the on-screen keyboard manually if they need it.
Preferably a solution which avoids changing the global settings of the machine.
More Info: The text input field needs to be able to receive focus and accept keyboard input from the bar-code and rfid scanners attached to the terminal.
Try
$("#textbox1").attr("readonly", "readonly");
or
$("#state").attr("readonly", true);
Thanks
AB

Categories