Your browser doesn't support the features required by impress.js, so you are presented with a simplified version of this presentation.
For the best experience please use the latest Chrome, Safari or Firefox browser.
Key Features:
- Keyboard, Mouse, Touch, and Multitouch
- Combos (a-s) and Ordered Combos (a->b)
- Sequences (up up down down ...)
- Combine different input types (shift-click)
- Speech Recognition
- Clap Detection (Clap On Clap Off!)
- Idle Detection
- Gamepad Support
- Window Events (Resize, fullscreen, and more!)
- More! Much More!
Competition: Mousetrap
- Only works with US keyboard layouts
- Only does keyboard events (can't shift-click)
- Can't use a bound key in a sequence
- Thinks 'ctrl-shift' different from 'shift-ctrl'
- Can't set context (this) for callbacks
- No way to prevent key repeat
- Can't check key state (no isDown())
- Alt-Tab breaks it
- No scopes
- Minified and compressed size: 2.3kb
Competition: Keypress
- Only works with US keyboard layouts
- Only does keyboard events
- Can't use a bound key in a sequence
- Thinks 'ctrl-shift' different from 'shift-ctrl'
- It can get complicated
- Can't check state of pressed keys
- No scopes
- Correctly handles Alt-Tab!
- Minified and compressed size: 4.9kb
Competition: Keymaster
- Only works with US keyboard layouts
- Only does keyboard events
- Doesn't support numpad (what? ¯\(°_o)/¯)
- Thinks 'ctrl-shift' different from 'shift-ctrl'
- Alt-tab breaks it
- Hasn't been updated in years
- ...but it has scopes!
- Impressive featureset for its size
- Minified and compressed size: 1.8kb
How do you use
HumanInput?
// Create an instance of HumanInput:
var HI = new HumanInput(window);
// Set a callback for a given event:
HI.on('a', aKeyPressed);
// Mix & match event types:
HI.on('a-s-click', doStuff);
// Use selector syntax for #id and .class:
HI.on('click:.someclass', clickSomeclass);
// Bind multiple events at once:
HI.on(['ctrl-a n','esc esc n'],nextWindow);
// Check state at any time:
HI.isDown('shift-a') == true;
Let's talk about Advanced Features
Aliases and Event Maps
HI.aliases.invoke = 'ctrl-a';
HI.aliases['★'] = 'ctrl-b';
HI.on('invoke n', newWindow);
HI.on('★', newBookmark);
var myMap = {'w': 'moveup'};
// Apply the eventMap at instantiation:
var HI = new HumanInput(
window, {eventMap: myMap});
HI.on('moveup', (e) => {
HI.log.info('moveup'); });
Filter Function
// Skip events if conditions are met
HI.filter = function(e) {
if (e.target.tagName == 'TEXTAREA') {
return false; // Skip event
}
return true; // Proceed normally
};
Record a Keystroke