Android Pop-UP Keyboard

Hi All.
Most Android Apps have a [GO] key on the pop up keyboard that hides the keyboard and enters what was typed. The only way I find to hide the keyboard is by tapping an empty area on the screen or another field. I am getting a bit of flak regarding this. Can you point me in the right direction on how to implement the app similarly to what I described above as the norm?


I spent a bit of time researching this, and wasn’t able to find a way to get the Go button to close the keyboard. Anybody else have an answer?

Earlier, I had the need to disable the android ‘Back’ button and implemented a function in the Global Code tab. Currently I have modified the function to use the android back key to close the soft keyboard. It works, but not exactly what I needed:

document.addEventListener("backbutton", onBackKeyDown, false);
function onBackKeyDown(event) {
    if($("#myModal").hasClass("in")) {
End JavaScript

Your snippet gave me an idea. Maybe the Go key sends a character when it is hit?

Sure enough - ‘Enter’ is returned. All that’s left is to remove the focus from the input field and the keyboard disappears.


Function TextBox1_onkeypress(event)
  If event.key = "Enter" Then TextBox1.blur()
End Function


TextBox1.onkeypress = function(event) {
    if (event.key == "Enter") {
1 Like

Yes, it looks like the [GO] key is the enter key. Since some text areas accept [Enter] during input as a new line (vbCrLf); it would be better to intercept another key (The right Arrow would be perfect) as a way to close the soft Keyboard. How do you go about getting the names for the event.key variable? Is the right arrow simply “Tab”?

Do a console.log(event) inside the function.

Hook up the Chrome Remote Debugger to see the output.

If you are running your app on a PC you can use Function window_onkeydown(e). This works on Android as well but there are no tab or arrow keys on the on-screen keyboard :

Function window_onkeydown(e)
  If keycapture = "off" Then Exit Function 
  keyval = e.keyCode
  alert("keyval: " & keyval)
  If keyval = 9 Then 'Tab was pressed
    alert("tab was pressed")
  End If
End Function 

You can turn this function on only when needed.

The End key is 35 and the right arrow is 39


but blur() doesn’t work.
I’ve put that Code into the sample …\bootstrap\input.nsx

Function Input2_onkeypress(event)
  If event.key = "Enter" Then Input2.blur() 
End Function

Function Input3_onkeypress(event)
  If event.key = "Enter" Then Input2.focus() 
End Function

No reaction with blur(), focus() works fine.
Also tried it with sample …\NSB.InputBox.nsx

Notice that johnC’s sample code looks at window_onkeydown, not Input2_onkeypress.

I had a look at your code. The topic was how to get rid off the “soft”-keyboard after pressing “go” at your android. is there any help with johnC’s code?

Did you try John’s code? (I have not).

No, I did not. 'cos it’s not a solution for the problem.

Why not? The Function window_onkeydown(e) should help you trap the Enter key.

You can do it with _onkeypress. the problem is that .blur() doesn’t work.

Just tried it here on an Android device running the latest version of Android. This worked fine:

Function TextBox1_onkeypress(event)
  If event.key = "Enter" Then TextBox1.blur()
End Function

The keyboard went away when Go was tapped.

That’s jQuery Mobile!
Try …\bootstrap\input.nsx
or …\NSB.InputBox.nsx

btw Tab always works, without any code.

This code in bootstrap while entering text into the input control works ok for me:

Function window_onkeydown(e)
  keyval = e.keyCode
  alert("keyCode: " & keyval)
End Function 

But the nsb.inputBox does not trap key strokes. Would be nice if it did.

Thanks, John