Skip to content

philipforget/Keanu

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 

#Keanu!

Keanu is a simple javascript keychording library for capturing multiple, simultaneous keyboard events. Useful for catching system-like shortcuts like Control-Shift-c.

Examples

Setting a shortcut is useful for UI where the user wants to record a new shortcut to be listened for.

// First create a shortcut to be listened to
keanu.get_shortcut({
    max_keys: 4,
    // Every time pressed keys are changed, on_update will be triggered
    on_update: function (shortcut) {
        if (shortcut) {
            console.log("Shortcut updated to " + shortcut);
        }
    },
    // When the final shortcut is set, on_set will be triggered
    on_set: function (shortcut) {
        if (shortcut) {
            console.log("Shortcut set to " + shortcut);
        }
    },
    // Regardless of the shortcut being set or canceled, on_complete will be triggered last.
    on_complete: function () {
        console.log("All done here");
    }
});

It's even simpler if you just want to listen for keanu-style shortcut events. Here's the code to set up a global listener.

keanu.listen(function (shortcut) {
    if (shortcut == "16_17_67") {
        console.log("It's happening!");
    }
});

About

Javascript keychording helper

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published