Giter VIP home page Giter VIP logo

plusastab's Introduction

PlusAsTab javascript library

Donate $5 now Donate $25 now Donate $100 now More options

A jQuery plugin to use the numpad plus key (configurable) as a tab key equivalent.

⚠️ This project has been archived

No future updates are planned. Feel free to continue using it, but expect no support.

With PlusAsTab, elements can be marked as plussable, allowing the user to use the + on the numeric keypad (numpad or tenkey for short) to navigate page. For numeric input it is closer than the tab key and therefor increases input speed and allows for one-handed entry in multiple fields.

  • The normal tab key is unaffected and works as usual.
  • Plussable fields that may need to have the plus character entered into them can still use the + key on the typewriter keys.
  • Laptops may not have physical numpads, but instead it is emulated with the Fn key (or similar). PlusAsTab is not targeted at laptop users. It is possible to use an external/separate USB numpads though.

Get it

bower install jquery-plusastab

Demos

Usage

HTML

<!-- Can be applied to plussable elements one by one -->
<input type="text" data-plus-as-tab="true" />
<textarea data-plus-as-tab="true"></textarea>
<a href="https://joelpurra.com/" data-plus-as-tab="true">Joel Purra</a>

<input type="button" value="This button has not been enabled for plussing" />

<!-- Can be applied using a class name -->
<input type="text" value="" class="plus-as-tab" />

<!-- Can be applied to all plussable elements within a container -->
<ol data-plus-as-tab="true">
	<li><input type="checkbox" /> Checkbox, plussable</li>
	<li><input type="checkbox" /> Another checkbox, plussable</li>

	<!-- Can be explicitly exluded from plussing -->
	<li><input type="checkbox" data-plus-as-tab="false" /> Checkbox, plussing disabled</li>
	<li><input type="checkbox" class="disable-plus-as-tab" /> Another checkbox, plussing disabled</li>
</ol>

Javascript

// Apply plus as tab to the selected elements/containers
$(selector).plusAsTab();

// Exclude plus as tab to the selected elements/containers
$(selector).plusAsTab(false);

// Equivalent static function
JoelPurra.PlusOnTab.plusAsTab($(selector));
JoelPurra.PlusOnTab.plusAsTab($(selector), false);

// Change the "tab" key from "numpad +" to something else
JoelPurra.PlusAsTab.setOptions({
  // Use enter instead of plus
  // Number 13 found through demo at
  // https://api.jquery.com/event.which/
  key: 13
});

// You can assign multiple keys as "tab" keys; just pass an array
JoelPurra.PlusAsTab.setOptions({
  // Use the enter key and arrow down key as tab keys
  key: [13, 40]
});

Using another key (or keys) instead of numpad plus

PlusAsTab should be able to intercept most keys, since it listens to the keydown event. To change the key, use JoelPurra.PlusAsTab.setOptions({key: YOUR_KEY});, where YOUR_KEY is a number that you can find by using the jQuery event.which demo. In case you want multiple keys to function as tab, use an array; for example [13, 40, 107] for the enter key, arrow down key and numpad plus key.

Plussable elements

Elements that can be focused/tabbed include <input>, <select>, <textarea>, <button> and <a href="..."> (the href attribute must exist and the tag must have some contents). These are also the elements that can be plussable.

Note that <input type="hidden" />, <a> (without href or empty contents), disabled="disabled" or display: none; elements cannot be focused.

Static elements

Static plussable html elements can have, or be contained within elements that have, the attribute data-plus-as-tab="true" or the class .plus-as-tab. They are enabled automatically when the library has been loaded/executed.

Dynamic elements

Dynamic elements are initialized to PlusAsTab in code after adding them to the DOM; $("#my-optional-input").plusAsTab(). This is not necessary if the added element already is contained within an element that is marked for plussing. You can also call .plusAsTab() on containers.

Containers

When PlusAsTab is applied to html containers, like <div>, <ul> or <fieldset>, all plussable child elements are implicitly plussable. This applies to static html and subsequently added child elements.

Disabling plussing

Plussable elements, or containers with plussable children, marked with class .disable-plus-as-tab or attribute data-plus-as-tab="false" never have plussing enabled. Disabling can also be done dynamically on elements/containers with $(selector).plusAsTab(false). If plussing is disabled for the element when it receives focus, or any of its elements parents, it will not be tabbed. Disabling plussing takes precedence over enabling plussing.

Original purpose

Developed to increase the speed and usability when entering numbers in consecutive fields in a web application for registering and administering letters. Examples of plussed fields are consecutive date, zip code and quantity fields. Any other text fields, dropdowns with sensible defaults and secondary buttons were also set as plussable to maximize the flow.

Dependencies

PlusAsTab's runtime dependencies are

Browser compatibility

Should be about as compatible as jQuery is, since most functions depend on jQuery's normalization. You are engouraged to run the PlusAsTab test suite and then report any issues.

Todo

  • Break out reusable key press functions from tests.
  • Implement a "real world" demo.

See also

PlusAsTab's sister projects.

  • SkipOnTab - speed up form filling by skipping some fields in the forward tab order.
  • EmulateTab - the tab emulator used by both SkipOnTab and PlusAsTab.

PlusAsTab copyright © 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Swedish Post and Telecom Authority (PTS). All rights reserved. Released under the BSD license. Developed for PTS by Joel Purra. Your donations are appreciated!

plusastab's People

Contributors

adam-lynch avatar bitdeli-chef avatar joelpurra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

plusastab's Issues

Using with tabindex

Hi. I'm using plusastab so users can press enter to skip between inputs. This works fine until I apply tabindex to the fields (i have to do that dynamically). Tab follows the tabindex but the enter key ignores it and skips between every element.

I tried using skipOnTab but that has the same effect.

plusastab + skipontab

Hi,
is there a way to skip using predefined key like enter, not using default tab key.

when i using plusastab via Static elements the some input that i skip (not using data-plus-as-tab) is stuck and make trigger submiting the form.

case
input 1
input 2
input 3
input 4
..
input 11
input 12
input 13
input 14
..
input 99

I want some input can be skipped using enter for speed purpose. for example, i want to skip input 11 - input 14. can you guide me how to do it using predefined key

npm module

same as emulatetab add plusastab in npm !

Tab emulation doesn't cause text to be pre-selected / highlighted

My web app is used by data-clerk type folks who were accustomed to a former green-screen terminal app where the [+] numpad key could be used to move around the screen.

This library is phenominal for making my app a little more navigable.

ISSUE: Using the "plus" key doesn't seem to cause certain text fields to have their contents highlighted for replacement. So, if you're tabbing through a form to replace text in every cell, you have to either grab the mouse and highlight or hit a bunch of BACKSPACE keystrokes.. whereas the preferred method would be to just "plus-type-plus-type-plus"

I'll be the first to admit my MVC app has a ton of other script running which could be interfering with your pure OOTB functionality.. but.. the TAB key still works as expected (highlighting the pre-existing text as focus is brought to each field), but using the [+] key does not work in the same way.

Does not consider tabindex

This plugin does not consider tab indexes as it iterates through data-plus-as-tab elements.

<input tabindex=1 data-plus-as-tab="true"/>
<input tabindex=3 data-plus-as-tab="true"/>
<input tabindex=2 data-plus-as-tab="true"/>
  • Using the tab key it will go to the first input, then the last input and finally the middle input.
  • Using this plugin it will go to the first input, middle input then the last input.

possibility to have multiple key-events captured

At this moment it is not possible to have multipe keys being catched and replaced with tab-behaviour.
for example have both enter-key and keydown behaving as tab.

JoelPurra.PlusAsTab.setOptions({
key:13,
key:40
});

OR

JoelPurra.PlusAsTab.setOptions({
key:13,40
});

many thanks,
Bram

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.