Giter VIP home page Giter VIP logo

on-screen-keyboard's Introduction

On Screen Keyboard

Version 1.0.2

Introduction

On-Screen Keyboard is a jQuery plug-in which allows a fluid-width keyboard to be launched when the user clicks on an element.

Demo

A demo is available here.

How to use it

  1. Add jquery.onScreenKeyboard.js and onScreenKeyboard.css to your project, along with jQuery. Optionally also add jQuery UI with the Draggables widget if you would like your users to be able to move the keyboard around the screen.
  2. Create your form or input elements.
  3. Add the following JavaScript to your page, to be executed on load:
	$('.osk-trigger').onScreenKeyboard();

...where .osk-trigger is a selector for the input elements you would like to trigger the keyboard.

A demo is available in demo.html.

Additional settings

Additional settings can be used to customise the keyboard, and should be added as a parameter within curly braces:

  • draggable: Requres jQuery UI with Draggables Whether or not the keyboard is movable (default false; must be boolean).
  • rewireReturn: Make the return key submit the form instead of inserting a linebreak (default false; must be either boolean false or a string to replace 'return' with on the key).
  • rewireTab: Make the tab key cycle through input elements in the order they appear in the DOM instead of inserting a tab (default false; must be boolean).
  • topPosition: The top CSS property of the keyboard (default 20%; must be a string suitable for CSS, i.e. one ending in a measurement unit).
  • leftPosition: The left CSS property of the keyboard (default 30%; must be a string suitable for CSS, i.e. one ending in a measurement unit).

An example of these in practice:

	$('.osk-trigger').onScreenKeyboard({
		'draggable': true,
		'rewireReturn': 'search',
		'rewireTab': true
	});

In addition to these universal settings, you can change the keyboard on an input-by-input basis using the following parameters added to your input elements under the attribute data-osk-options, separated by spaces:

  • disableSymbols allows you to disable the symbol keys.
  • disableTab allows you to disable the tab key.
  • disableReturn allows you to disable the return key.

An example of these in practice:

	<input type="text" id="input1" class="osk-trigger" data-osk-options="disableReturn disableTab">

jquery.onscreenkeyboard.js contains the HTML for the keyboard at the bottom. As long as class names remain the same, this can be changed however much you like. The keyboard can only be written manually (e.g. custom non-us keyboard layouts) - the plugin is able to pick it up. Keep in mind that the character entered into the input box is taken directly from the contents of the li element for the pressed key (with exceptions for special keys such as return and tab, when not overridden, and backspace).

onscreenkeyboard.css can also be edited to customise the keyboard's design. The first section, "Keyboard Structure" should be mostly left alone. The second section contains definitions for colour and keyboard position.

Compatibility

  • Internet Explorer 7+
  • Firefox 3+
  • Chrome
  • Opera (see note below)
  • Safari

Issues

  • In Opera, the widths of keys on the upper three rows will not match that of the space bar. This is due to the way Opera deals with sub-pixel values.

Author and Acknowledgements

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.