GithubHelp home page GithubHelp logo

boxhide.js's Introduction

boxhide.js

jQuery plugin: Assign specific key events to a callback

This plugin is great for developers who want to offer keyboard short cuts for their users.

Structure:

3 items are needed

  1. Selector Ex: $("#input_sample")
  2. Key-set Ex: $("#input_sample").boxhide([17, 69, 84]) [These are Cntrl, e, t]
  3. Callback Ex: $("#input_sample").boxhide([17, 69, 84], function() { console.log('Event Fired!'); });

Using the above structure, you can also compound key-sets with more callbacks:

$("#input_sample").boxhide([17, 69, 84], function() { console.log('Event Fired!'); });
$("#input_sample").boxhide([17, 69, 84], function() { console.log('Different Event Fired!'); });

Using the same key-set you can register multiple callbacks but never the exact same callback avoiding the same event being triggered twice.

Likewise you can register different key-sets with the same callback:

$("#input_sample").boxhide([17, 69, 81], function() { console.log('Event Fired!'); });
$("#input_sample").boxhide([17, 69, 84], function() { console.log('Event Fired!'); });

This allows you to define different key-sets but have the same callback registered and triggered.

Examples uses:

<input type='text' id='input_sample'>
<input type='checkbox' id='box' />

Above there are two form elements. The first has an id of input_sample and the second has an id of box

In order to register a series of key events with them, simply do the following:

// 17 = Cntrl, 69 = e, 84 = t, 81 = q
$("#input_sample").boxhide([17, 69, 84], function() { console.log('Event Fired!'); });
$("#input_sample").boxhide([17, 69, 81], function() { $("#box").click(); });

Lastly, you can register the body element to boxhide.

$("body").boxhide([17, 81], function() { $("#input_sample").remove(); $("#box").remove(); });

boxhide.js's People

Contributors

ibeals avatar

Stargazers

Alex Kinnee avatar

Watchers

James Cloos avatar  avatar

Forkers

pvitaly

boxhide.js's Issues

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.