Skip to content

Version 2.0 #559

@Mottie

Description

@Mottie

I am planning on rewriting this plugin in plain JS or React. The following list are changes that are being planned. Please feel free to comment:

Remove

  • Remove jQuery dependency.
  • Remove built-in jQuery UI position utility support. Use the beforeVisible or visible callback to position it.
  • Remove position option - see above.
  • Remove customLayout option; The layout option will accept the custom layout instead.
  • Remove '{accept} {space} {cancel}' row from every language layout - we'll use the addRow method to add these instead (described below).

Change/Fix

  • Improved deadkey support. Allow various input methods:

  • Better support, demo and documentation for use with Codemirror - see Question: possible to use with codemirror, ace, etc? #306 & Codemirror and keyboard #551.

  • Better support, demo and documentation for use with Ace editor - see Question: possible to use with codemirror, ace, etc? #306.

  • Better support, demo and documentation for plugins like select2, chosen, selectator and selectize.js - see problem with select2 boxes #349 & keyboard special Key to call "chosen" with jquey data  #464.

  • Find a way to override the Alt key in Windows to allow switching keysets.

  • Use tabindex properly when switching inputs - see Option to keep select, checkboxes, .. in taborder #472.

  • Set display option to allow modifying the text of any key - see Replace label on key #555.

  • Split keyboard layouts, similar to the extender extension, but add to different containers like a split physical keyboard.

  • Expand keyaction definitions. Possible syntax:

    Keyboard.keyActions = {
    
      accept: {
        // action key aliases; can replace with a regular expression
        aliases: [ "{a}", "{accept}" ],
        // if null, get key content from language display definition;
        // if it doesn't exist, the keyAction name is used
        content: null,
        // extra class names added to key (defaults contained in Keyboard.css)
        classes: "accept-me",
        tooltip: "",
        // key action to perform
        action : function (kb) {
          kb.accept();
        },
        // add keys that are allowed to enter into the input/textarea if
        // `restrictInput` is set
        acceptedKeys: []
      },
    
      spacer: {
        aliases: [ /^\{sp:((\d+)?([\.|,]\d+)?)(em|px)?\}$/i ],
        content: function(kb, key) {
          // kb = keyboard object
          // key = alias minus the wrapping {}
          // not perfect globalization, but allows you to use
          // {sp:1,1em}, {sp:1.2em} or {sp:15px}
          let margin = parseFloat(key.replace(/,/, '.')
            .match(/^sp:((\d+)?([\.|,]\d+)?)(em|px)?$/i)[1] || 0),
    
            // previously {sp:1} would add 1em margin to each side of a 0 width
            // span now Firefox doesn't seem to render 0px dimensions, so now we
            // set the 1em margin x 2 for the width
            width = (key.match(/px/i) ? margin + 'px' : (margin * 2) + 'em'),
    
            span = document.createElement('span');
    
          span.css.width = width;
          return span;
        },
        classes: "keyboard-spacer",
        tooltip: ""
        // action: null,
        // acceptedKeys: []
      },
    
      panic: {
        aliases: [ "{panic}", "{!!!}" ],
        content: "Panic!!!",
        classes: "keyboard-action-panic",
        tooltip: "",
        action: function (kb) {
          Modal.open({
            media: "assets/panic.mp4",
            onClose: function() {
              kb.insertText("Ahhhhh!");
            }
          });
        },
        acceptedKeys: "panic!".split("")
      }
    
    };
  • Add internal methods to change key/keyactions to auto-suggest characters (e.g. suggest Pinyin characters based on input - see pinyin support? #322).

  • Rename tabNavigation to tabBehavior and give it 3 options (see Pressing Tab button inserts indentation in textarea. How to prevent it? #692):

    • "disable" - do nothing
    • "insertTab" - textarea only
    • "navigate" - textarea & input

Add

  • Support for contenteditable elements - see Bind to DOM elements other than textarea and input. #208 & Keyboard not working with editable tables (contenteditable="true") #540.

  • Support for input masks - new, or integrate an existing masker? see bad conflict with maskedinput #89 & Input Mask Integration #201.

  • Allow initialization on the document & use a delegated binding on input/textarea - see Can it initialise globally? #558.

  • Better support, demo and documentation for use with Mathquill - see Mathquill for input area #423.

  • Wrap each row with a div to support row styling (e.g. row spacing).

  • Physical keyboard shortcuts?

  • Add layout & language selector to keyboard popup - see language pull down inside keyboard and dynamically loading script #110, Set language #355 & Can you add a keyboard layout change feature like this one? #532:

    • Allow chosing which layouts & languages to include.
    • Allow toggling the display of selectors.
    • Allow enable/disabling of these selectors.
  • Add a customizable tool bar:

    • Set location, e.g. across the top or bottom.
    • Include custom keys: lock/unlock, enable/disable, etc.
    • Include layout & language selectors.
  • Add a key:

    • Allows adding a key or action key to any layout without having to copy/paste a current layout and making it "custom".

    • Possible syntax:

      Keyboard.addKey("{test}", {
        // keyset(s); opts "all", "normal", "shift", "meta", etc
        // should allow multiple settings, e.g. "normal,shift" (add to 2+ keysets)
        to: "all",
        // where to add row & column (zero-based index)
        row: 0,
        column: 0
      });
  • Add a row:

    • Allows adding a row of keys to any layout without having to copy/paste a current layout and making it "custom".

    • Possible syntax:

      Keyboard.addRow("{accept} {space} {cancel}", {
        // keyset(s); opts "all", "normal", "shift", "meta", etc
        // should allow multiple settings, e.g. "normal,shift" (add to 2+ keysets)
        to: "all",   
        // where to add the row
        // "append", "prepend", or "2" (zero-based row index)
        loc: "append"
      });
  • Replace a row

    • Allows replacing an existing row of keys in any layout without having to copy/paste a current layout and making it "custom".

    • Similar to javascript .replace() and allow using regular expressions to match a row.

    • Possible syntax:

      // syntax: replaceRow({original row}, {new row});
      Keyboard.replaceRow("{accept} {space} {cancel}", "{a} {space} {c}");
      // or
      Keyboard.replaceRow(/\{accept\}/g, "{a} {space} {c}");
  • Remove a button from a defined layout

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions