Prevent auto-focus of input when set alwaysOpen to true #150

Closed
anthonynoisestreet opened this Issue Mar 27, 2013 · 6 comments

Projects

None yet

3 participants

@anthonynoisestreet

I want the keyboard to stay open all the time, so I set alwaysOpen to true. The side effect, however, is that when the page is loaded it is automatically focused on the input, which is not what I want. I'd prefer the page to load normally so that the user is shown the top of the page first, and not the middle of the page, where the input is situated. Is there anyway I can accomplish that? Thanks in advance for your help.

@Mottie
Owner

Hi @anthonynoisestreet!

That may be a bit difficult to accomplish "neatly".

The only way I can think of to not auto-focus would be to rewrite the plugin with another option to not auto-focus, or clear the focus after the keyboard has been initialized. The ugly part of it is that you'd need to use a setTimeout to clear it (demo).

$('#keyboard').keyboard({
    alwaysOpen: true,
    initialized : function(e, keyboard, el) {
        setTimeout(function(){
            keyboard.$preview.blur();
        }, 550); // use 550 because internally it uses 500 (for IE)
    }
});

This isn't a very clean solution to me, but I've been extremely busy lately and haven't had much time to work on projects, so I'll look into adding an option when I have some time.

@anthonynoisestreet
@Mottie
Owner

I'll try to look at this for you some time later today.

@anthonynoisestreet
@Mottie
Owner

I'm guessing this issue has been resolved with the addition of that new option, so I'm closing it. I hope it works for you!

@Mottie Mottie closed this May 6, 2013
@carlo-m

I have a similar problem. I do want it to focus on an input, but the first one (keyboard) not the last one. HELP!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment