强制在Android上打开键盘 [英] force keyboard open on android

查看:197
本文介绍了强制在Android上打开键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何强制在Android浏览器(4.0-可能更少)上打开键盘吗? 我尝试了此解决方案,但它不适用于我.

does anybody knows how to force keyboard open on android browser (4.0 - maybe less)? i tried this solution and it does not worked for me.

在项目中,我试图使文本输入正常工作,但是提交(通过jQuery拦截)后,它保持了焦点,但是键盘消失了.

in project i am trying to get a text input working, but after submitting (intercept by jQuery) it holds focus but the keyboard disappears.

摘要:

$('#typer').blur(function () {
    $(this).focus().click();
});

$('#typer').bind('keyup', function (e) {
    var input = $.trim($(this).val());
    // some lines of code..
    $(this).val('').focus(); // clean up
}

iOS也很有趣..但尚未经过测试.

iOS is also interesting.. but not tested yet.

推荐答案

每当文本输入字段处于焦点位置时,Android就会拉起软键盘. Android上的执行"或完成"按钮可以作为表单提交使用,因此输入文本会失去焦点,键盘也会消失.用户希望按下"Go","Done"或"Enter"后键盘会消失-因此Android遵循此规则.由于从技术上讲,您已移至其他窗口,因此将注意力重新集中在场的模糊上并不会起到太大作用.

Android pulls up soft keyboard whenever text input field is in focus. "Go" or "Done" button on Android works as form submit, therefore input text looses focus and keyboard disappears. User expects the keyboard to disappear after "Go", "Done" or "Enter" is pressed - so Android follows this rule. Forcing re-focus on field's blur will not do much since technically you moved to a different window.

$('body').click(function() { $('#typer').focus(); }

可以提供部分解决方案,用户必须单击页面正文中的任何位置一次,以便typer重新获得焦点.这将导致OS移回浏览器活动"并集中输入字段.该小提琴将其显示为示例: http://jsfiddle.net/Exceeder/Z6SFH/(使用http://jsfiddle.net/Exceeder/Z6SFH/embedded/result/)

can provide a partial solution, whereby user has to click once anywhere in the body of the page for the typer to re-gain focus. It causes OS to move back to browser Activity and focus the input field. This fiddle shows it as an example: http://jsfiddle.net/Exceeder/Z6SFH/ (use http://jsfiddle.net/Exceeder/Z6SFH/embedded/result/ on your Android device)

除了编写类似于PhoneGap的包装程序来控制键盘的imeOptions之外,我不知道有任何解决方案可以解决此问题.

Other than writing a PhoneGap-like wrapper to control imeOptions of the keyboard, I am not aware of any solution that can solve this problem.

这篇关于强制在Android上打开键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆