How to display a custom keyboard

眉间皱痕 提交于 2019-12-23 05:20:44

问题


I am creating a Worklight 6.1-based app with Dojo.

I want to present a 10-key keyboard to the user instead of the standard OS keyboard. How would I go about doing this?

I've tried the following, but it does not bring up a numbers-only keyboard. In iOS it brings up the full keyboard, only with the view that has numbers and $%^&* keys.

<input type='number' data-dojo-type='dojox.mobile.TextBox'>

Any suggestions?


回答1:


To successfully display a numeric keyboard you need to add the pattern attribute to the input element, like so:

<input data-dojo-type="dojox.mobile.TextBox" type="number" pattern="\d*">

I do not have an Android device, but it should work there as well.
Note that unlike in iOS where there is only 1 keyboard, in Android a user can install custom keyboard and it could be that not all keyboards will support the full set of customizability available...

There is nothing Worklight can do about that. (Worse case scenario you can write a Cordova plug-in to create a custom keyboard of your own, but it's unlikely you'll need to do that).

Here is how it looks like:

Here is some more reading materials on customizing a keyboard:

  • http://bradfrostweb.com/blog/mobile/better-numerical-inputs-for-mobile-forms/
  • http://www.html5rocks.com/en/tutorials/forms/html5forms/
  • https://about.zoosk.com/en/engineering-blog/mobile-web-design-use-html5-to-trigger-the-appropriate-keyboard-for-form-inputs/
  • http://danielfriesen.name/blog/2013/09/19/input-type-number-and-ios-numeric-keypad/
  • http://www.wufoo.com/html5/attributes/10-pattern.html
  • Google


来源:https://stackoverflow.com/questions/22867473/how-to-display-a-custom-keyboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!