Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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

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

anthonynoisestreet opened this issue Mar 27, 2013 · 6 comments

Comments

@anthonynoisestreet
Copy link

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
Copy link
Owner

Mottie commented Mar 27, 2013

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
Copy link
Author

Once again, thanks for your quick response. I tried your approach, but it
didn't work, because the effect of the browser shifting the viewport to the
middle of the content still exists, and blurring the focus after that does
nothing to help prevent that.

I understand your difficulty, no problem - but just in case it becomes
necessary to undo the effect, do you think you can tell me which function
to alter, just for this one time project? I was going through
jquery.keyboard.js and commenting out the base.$preview.focus(); parts just
to test it out, but nothing.

Cordially,
Anthony

On Wed, Mar 27, 2013 at 2:22 PM, Rob G notifications@github.com wrote:

Hi @anthonynoisestreet https://github.com/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.

$('#keyboard').keyboard({
alwaysOpen: true,
initialized : function(e, keyboard, el) {
setTimeout(function(){
keyboard.$preview.blur();
}, 550);
}});

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.


Reply to this email directly or view it on GitHubhttps://github.com//issues/150#issuecomment-15506110
.

@Mottie
Copy link
Owner

Mottie commented Mar 27, 2013

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

@anthonynoisestreet
Copy link
Author

Thanks a lot.:)

Cordially,
Anthony

On Wed, Mar 27, 2013 at 8:37 PM, Rob G notifications@github.com wrote:

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


Reply to this email directly or view it on GitHubhttps://github.com//issues/150#issuecomment-15520722
.

@Mottie
Copy link
Owner

Mottie commented May 6, 2013

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 as completed May 6, 2013
@carlo-m
Copy link

carlo-m commented Jun 21, 2013

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
Projects
None yet
Development

No branches or pull requests

3 participants