Close Virtual Keyboard programmatically when user hits enter/done - android

I'm currently developing an Angular App that is meant to run on tablets. I have a fake form composed of different lines with a textfield each. I want that when the user types a value inside one of those fields and hits enter the keyboard closes until he hits again a textfield.
Something like: "touch field -> open keyboard -> insert value -> hit enter -> hide keyboard".
Is this possible or is a built-in behavior of Android and it is not avoidable?

You could try dispatching events manually or turning your field into readonly until it is clicked into/refocused again or something like that.

Related

How do I stop moving focus on Enter keypress in Nativescript (Android)?

Playground example: https://play.nativescript.org/?template=play-vue&id=FZ3GR1&v=4
I'm using Nativescript-Vue on an Android device, if you type a value into the first textfield and then press enter, focus is moved to the second textfield.
How do I stop this? I do not want the focus to change at all as I will be handling the Enter keypress. I can move the focus back but I would rather it didn't move at all.
I feel I'm missing something very obvious!?
Nativescript's TextField has a property called returnKeyType that sets the soft keyboard's return type. You can set it to done if you want to just close the keyboard.
<TextField returnKeyType="done"></TextField>
More information about that in the docs

How to tap a button with one touch, when keyboard is open (instead of 2)

I have the keyboard open in my app, I want the user to be able to type, and then tap a colour selector widget I have made (which changes text colour). The problem is that it takes 2 taps, the first one closes the keyboard, the second one actually selects my colour picker. Is there a way to make this one tap? and also keep the keyboard open if possible, so they can change colour then go back to typing without focus issues.

Replace Go button on soft keyboard with Next in Phonegap

Phonegap input type text show Go button on soft keyboard, I have multiple text boxes so want Next button on keyboard so user can move easily and on last input want Go so user can press to submit form.
And on Android kitkatt keyboard top bar also not displaying Next|Prev buttons.
Having a "Next" button instead of "Go" for input type="text" would not be possible with Android as of now.
Android will always display "Go" button for form input fields irrespective of the position of the field you are at in the form. "Go" is basically reflecting the same behavior as of an "Enter" button on a normal browser & keyboard.
There are two possible hacks to come closer to what you need (still won't change "Go" to "Next" but will help "Go" act as "Next") -
Hack 1 - Hijack Enter key event & move focus to next fields
Like I mentioned the "Go" key replicates the "Enter" key, you can capture the enter key event using JavaScript & make it move focus to next fields in form until its your last field. Once last field reaches you can allow it to act as enter. So basically Go will keep moving focus to next fields until its your last field & then will submit the form.
I have answered a solution to a similar requirement here - How to trigger a Tab when user presses Enter, you can try implementing the same in your app.
DEMO LINK - http://codepen.io/nitishdhar/pen/Gxbhm
Hack 2 - Force form validation & move focus to next invalid fields
If you want to prevent users from submitting the form, you can put required validations on the form using java-script & if some field is not filled, upon pressing "Go" the focus of the cursor can be brought to the next "not filled" field. So in a way giving the impression of - "Pressing Go & moving to next field to be filled"
Try this plugin - http://jqueryvalidation.org/ this behaves in the way explained i.e moves focus to the next required or invalid field.
Also I think some android versions show some tab key on the keyboard to move between fields, buts its not Next.
All the best.

html phonegap android : numeric soft keyboard has next instead of go button

This is driving me crazy and I can't find the answer anywhere.
I have forms in my phonegap app. If the input type="text", the text keyboard pops up and "go" is displayed in the corner. When you click go, it submits the form. That all works as I would expect. But if I use input type="number", the number keyboard pops up and "next" is displayed in the corner. When you click next, if there is another input box before the button tag, it goes to that input. That's okay. . . not ideal, but makes sense. But if it is the last input field on the page, click "next" does nothing. It doesn't put focus on the button (even with tabindex) and it doesn't submit the form (ideal).
I'm using phonegap 1.3.0 and jquery 1.7 if any of that helps.
You can detect the next keyboard press by using the following bind in JQuery:
$('input').on('keydown', function(e){
if(e.which === 9) {
//your code here
}
});
The 'next' button emulates the tab keypress event on a keyboard, which is key code 9. Unfortunately, keypress and keyup events do not detect the next key event, so you need to bind it on keydown.
Hope that helps!
Okay, now I do have something that looks like an answer and quacks like an answer.
It's a horrible hack, and I am experiencing some side-effects at this point, but it's a small leap for mankind anyway.
Add an invisible text input to your form, which automatically submits the form as soon as it receives focus. Since it can only receive focus from the user pressing 'Next' or tabbing from the last number field, there should be a pretty solid logic in the user sequence.
<input type='text' style="opacity:0;" onfocus="javascript:$('#thisForm').submit();">
The side effects are:
the hidden form field will briefly be visible. You can avoid this by
using the onfocus handler to also re-focus on the number field that
was just left. Or you can set the width of the input to 0. The latter works best for me.
if you're using jQueryMobile like me, you're inviting horrible page transition ugliness on yourself, so if your form is in a dialog and submitting the form closes the dialog, be sure to set the dialog transition (when it is being opened from a previous screen) to 'none'.

Android:I need a slide in calculator type soft keypad a la iphone

I'm attempting to replicate on android an iphone app my company had developed externally.
My need is simple but it seems hard to achieve under android. I have three numeric edittext inputs. Each should take only decimal numeric values. So numbers 0-9 and "." or ",". On the iphone this was achieved by a slide in calculator style keypad with one of the buttons a "GO" button that when pressed hides the keypad and, if all the inputs have valid values triggers a calculation that displays values on the screen.
I've tried the android phone input type and this is very close to what I want but I have no idea how to replicate the go button. I have put a calculate button on the main interface itself but I can't get the keyboard to go again once it is opened.
So can I either
A. Modify the layout of the phone keypad in some way to change one of the buttons to be
GO (Calculate) and intercept the keypress or
B. Do I have to create my own keypad in which case how do I go about sliding it in and out
over the top of the current view?
thanks guys
See android:imeActionId and android:imeActionLabel for your GO button.

Categories

Resources