Disable the “Go” Button on the Android and iOS Virtual Keyboard

I recently had a project where I wanted to stop the “Go” button on the Android and iOS popup keyboard from submitting a form on my web application. Why would anyone want to do this?  In my case, I wanted to prevent accidental form submission (or “butt-dialing”) on my app.  I had implemented a “swipe-to-save” feature, but the “Go” button was bypassing this and submitting the form without requiring the swipe! After a lot of research and experimentation, I believe I have a solution that works!  I’ve tested it on iOS and Android (on HTC One).  Please let me know if it doesn’t work on your device!


The basic idea is to use JavaScript to detect key presses in your form <input> fields. When a key press is detected, you check to see if it was the “Go” key.  If so, you take focus off of the keyboard, which hides it, then return “false” to prevent submission of the form, and voila!  Pressing “Go” will make the keyboard disappear instead of submitting the form.

The Code

Here it the code, which uses jQuery (your code might use “$” instead of “jQuery”):

jQuery(document).ready(function() {
    jQuery('input').keypress(function(e) {
        var code = (e.keyCode ? e.keyCode : e.which);
        if ( (code==13) || (code==10))
            return false;

Make sure you are sourcing the jQuery file, then add this code to the JavaScript section of your code and you should be set! If you want some other action to happen after the keyboard disappears, you can add it right after the blur() line. Let me know if it works for you or not! – Brian

13 thoughts on “Disable the “Go” Button on the Android and iOS Virtual Keyboard”

  1. HI man,
    This is really helpful, But my problem hasn’t been solved yet.
    I wanted to give focus to the next form element on every click of go,(Like in tabindex)
    but this thing is not working in IOS 9
    Will be really grateful if you can help this one out


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share This