Skip to content

Tcheu/Keyboard

 
 

Repository files navigation

Originally posted by Jeremy Satterfield in his blog, jQuery plugins and on Snipplr. Currently maintained by Mottie.

Features (Demo)

  • An on-screen virtual keyboard embedded within the browser window which will popup when a specified entry field is focused.

  • The user can then type and preview their input before Accepting or Canceling.

  • Add custom keyboard layouts easily.

  • Add up to four standard key sets to each layout that use the shift and alt keys (default, shift, alt and alt-shift).

  • Add any number of optional modifier keys (meta keys) to add more key sets.

  • Each meta key set can also include the shift, alt and alt-shift keysets.

  • Position the keyboard in any location around the element, or target another element on the page (using jQuery UI position utility)

  • Easily modify the key text to any language or symbol.

  • Allow direct input or lock the preview window.

  • Set a maximum length to the inputted content.

  • Scroll through the other key sets using the mouse wheel while hovering over a key to bypass the need to use alt, shift or meta keys.

  • Easily type in characters with diacritics. Here are some default combination examples - it is possible to add more.

    • ' + vowel ( vowel with acute accent, e.g. ' + e = é )
    • ` + vowel ( vowel with grave accent, e.g., ` + e = è )
    • " + vowel ( vowel with diaeresis, e.g., " + e = ë )
    • ^ + vowel ( vowel with circumflex accent, e.g., ^ + e = ê )
    • ~ + certain letters ( letter with tilde, e.g. ~ + n = ñ, ~ + o = õ )
  • Enable, disable or add more diacritic functionality as desired.

  • Use callbacks and event triggers that occur when the keyboard is open or closed and when the content has changed, been accepted or canceled.

  • ARIA support (may not be fully implemented)

  • jQuery UI themes are used by default, but Bootstrap themes can also be applied.

  • Built in watermarking. It emulates HTML5's placeholder, if the browser doesn't support it.

  • Typing extension allows you to simulate typing into the keyboard for demo purposes or to assist user input.

  • Autocomplete extension will integrate this keyboard plugin with jQuery UI's autocomplete widget.

  • Multiple region specific keyboard layouts included in a separate directory. This is a work in progress and slowly growing.

Packages

  • Install using bower via bower install keyboard.
  • Install using npm via npm install virtual-keyboard.

Documentation

Wiki: Home | FAQ | Setup | Usage | Options ( Layout, Language, Useability, Actions ) | Methods | Theme | Log

To Do

  • Waiting for requests :)
  • Add more regional keyboard layouts.
  • Add an input mask extension. I think I'll try to make it compatible with this plugin.
  • Allow attaching a keyboard to a contenteditable element.

Known Problems

  • IE and Opera:
    • In a text area with multiple carriage returns, the caret positioning will be off when repositioning it with the mouse.
    • Using the right and left arrow keys to navigate through a text area with multiple carriage returns is problematic. The caret doesn't behave like in other browsers when moving from one line to the next. You can always reposition the caret using the mouse.
  • Opera: When pressing the tab key while inside a textarea, all browsers but Opera add the tab to the virtual keyboard textarea.
  • Safari: See the QWERTY Text Area demo with a locked input. While using the virtual keyboard to type, it enters the text in backwards! This is because textareas with a "readonly" attribute always returns zero for the caret postion.
  • Typing Extension:
    • When pressing "Alt", the key set will change to the alt key set, but the focus will be moved to the browser menu. Pressing it quickly a second time will return the focus. This is build into the browser and it isn't possible (as far as I know) to automatically restore the window focus the first time alt is pressed.
    • Holding down the Alt key and trying to type is also not possible since the Windows OS is assuming you are trying to type a shortcut key to access the browser menu. You can still click the keys in the alt key set with the mouse.
    • Simulated typing on the keyboard breaks when the CapLock is on. Still looking for a cross-browser solution.

Dependencies

  • Required
    • jQuery 1.4.3+
    • jQuery caret (included with source)
  • Optional
    • jQuery UI Positioning Utility (optional, if you position the keyboard yourself)
    • jQuery UI CSS (can be customized) / Bootstrap CSS
    • jQuery mousewheel plugin - allows using mousewheel to scroll through other key sets
    • jQuery UI Autocomplete widget - use with jQuery keyboard autocomplete extension

Contributing

  • Install node.js - this includes npm (node package manager).
  • Run npm install in the root directory.
  • Run npm install -g grunt-cli to install the grunt command-line interface.
  • Make any changes to the code.
  • Unit tests will be added later.
  • Run grunt to perform a new build in the /dist folder.
  • Submit a pull request from a branch other than the main.

Licensing

  • Keyboard code: MIT License for all versions.
  • Caret code by C. F., Wong (Cloudgen): MIT License
  • Layouts files: Most are under WTFPL, unless the file itself specifies otherwise.

Change Log

Only the latest changes will be shown below, see the wiki log to view older versions.

Version 1.22.1 (3/13/2015)

  • Core
    • Update keyboard.last.eventTime on keyboard visible.
    • Destroy method now removes all references. Fixes issue #337.
    • Close function is now called when stayOpen is true and clicking to open another keyboard.
  • Docs
    • Update password demo to close on second click. Fixes issue #336.
    • Update to use jQuery v1.11.4.
  • Typing Extension
    • Stop typing simulation on user interaction.
    • Add new and additional typeIn support for simulated keys:
      • caret left = {l}
      • caret right = {r}
      • delete = {d} (\\d removed)
      • tab = \t or {t}
      • backspace = \b or {b}
      • enter = \n or \r or {e}
    • Find virtual key using data-action attribute as it's value doesn't change with other languages.
    • Use keyaction functions instead of just inserting the text.

Version 1.22.0 (3/7/2015)

  • Add AMD/browserify support.
  • Add {del} key & modify {bksp} key.
    • The delete key allows deleting content to the right of the caret.
    • The backspace key still allows deleting content to the left of the caret, it's code was only tweaked internally to not use plain text to indicate a backspace.
  • Add {normal} key & deprecate {default} key:
    • The {normal} key is a duplicate of the {default} key.
    • Since "default" is a reserved javascript word, this key is being deprecated to prevent future issues.
  • last variable changes:
    • Rename last.value to last.val - it was inconsistent internally. This contains the current preview input value.
    • Add last.event - contains last DOM event object; saved by keypress, repeater and events set by the keyBinding option.
    • Add last.$key - jQuery object of the last virtual key used; it is set to an empty array when the physical keyboard is used.
    • Add last.layout - contains the name of the layout last used by the keyboard.
    • Update last.eventTime upon closing the keyboard. See issue #333 on how this can be useful.
  • Remove internal keyboard position setting
    • Absolute positioning is already defined in the css
    • The inline setting was interfering with alternative positioning.
  • Caret
    • Started centralizing caret positioning code.
    • Anticipating the possibility of swapping out caret positioning plugins, or using an input mask plugin.
    • A suitable alternatives has yet to be found; either way, more code adjustment will be necessary to make this work.
    • Set caret position to end when caret positioning isn't supported; it was previously returning a full selection.
  • Demo
    • Add jQuery UI theme switcher to the combined layouts demo.
    • Also added some missing layouts to the combined layouts demo.
  • Grunt build
    • Add a "grunt layout" build to build everything.
    • The default "grunt" build now ignores layout files as uglifying & concatenating layout files takes more time.

Version 1.21.3 (3/5/2015)

Packages

No packages published

Languages

  • JavaScript 96.8%
  • HTML 2.1%
  • CSS 1.1%