{"id":13426716,"url":"https://github.com/avocode/combokeys","last_synced_at":"2025-04-04T11:16:17.382Z","repository":{"id":23323902,"uuid":"26683992","full_name":"avocode/combokeys","owner":"avocode","description":"Web browser keyboard shortcuts. CommonJS, NPM.","archived":false,"fork":false,"pushed_at":"2022-02-12T22:12:04.000Z","size":926,"stargazers_count":674,"open_issues_count":20,"forks_count":29,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-03-26T23:37:32.548Z","etag":null,"topics":["combokeys","keyboard","keyboard-shortcuts","mousetrap"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/avocode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-15T15:31:27.000Z","updated_at":"2024-12-23T05:00:40.000Z","dependencies_parsed_at":"2022-09-17T19:12:04.663Z","dependency_job_id":null,"html_url":"https://github.com/avocode/combokeys","commit_stats":null,"previous_names":["policystat/combokeys"],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avocode%2Fcombokeys","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avocode%2Fcombokeys/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avocode%2Fcombokeys/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avocode%2Fcombokeys/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/avocode","download_url":"https://codeload.github.com/avocode/combokeys/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247166169,"owners_count":20894654,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["combokeys","keyboard","keyboard-shortcuts","mousetrap"],"created_at":"2024-07-31T00:01:42.461Z","updated_at":"2025-04-04T11:16:17.362Z","avatar_url":"https://github.com/avocode.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Combokeys [![Build Status](https://travis-ci.org/avocode/combokeys.svg?branch=master)](https://travis-ci.org/avocode/combokeys) [![js-standard-style](https://raw.githubusercontent.com/feross/standard/master/badge.png)](https://github.com/feross/standard)\n\nCombokeys is a JavaScript library for handling keyboard shortcuts in the browser.\n\nIt is licensed under the Apache 2.0 license.\n\nIt is around **3.3kb** minified and gzipped and **9.9kb** minified, has no external dependencies, and has been tested in the following browsers:\n\n- Internet Explorer 6+ (test suite works in IE9+)\n- Safari\n- Firefox\n- Chrome\n\nIt has support for ``keypress``, ``keydown``, and ``keyup`` events on specific keys, keyboard combinations, or key sequences.\n\n## Fork notice\n\nThis project was forked from [ccampbell/mousetrap](https://github.com/ccampbell/mousetrap).\n\nIt was forked because pull–requests were not being reviewed.\n\nThis fork's author intends to review pull–requests.\n\nMain changes are\n\n1. Refactored as CommonJS\n2. Doesn't automatically listen on the `document`. Instead, it is now a constructor and the element on which to listen must be provided on instantiation. Multiple instances possible.\n\n## Getting started\n\nGet it on your page:\n\n```js\nvar Combokeys;\nCombokeys = require(\"combokeys\");\n```\n\nInstantiate it for the entire page:\n\n```js\nvar combokeys = new Combokeys(document.documentElement);\n```\n\nOr, instantiate it for one or more specific elements:\n\n```js\nvar firstCombokeys = new Combokeys(document.getElementById(\"first\"));\nvar secondCombokeys = new Combokeys(document.getElementById(\"second\"));\n```\n\nAdd some combos!\n\n```js\n// single keys\ncombokeys.bind('4', function() { console.log('4'); });\nfirstCombokeys.bind(\"?\", function() { console.log('show shortcuts!'); });\nsecondCombokeys.bind('esc', function() { console.log('escape'); }, 'keyup');\n\n// combinations\ncombokeys.bind('command+shift+k', function() { console.log('command shift k'); });\n\n// map multiple combinations to the same callback\ncombokeys.bind(['command+k', 'ctrl+k'], function() {\n    console.log('command k or control k');\n    // return false to prevent default browser behavior\n    // and stop event from bubbling\n    return false;\n});\n\n// gmail style sequences\ncombokeys.bind('g i', function() { console.log('go to inbox'); });\ncombokeys.bind('* a', function() { console.log('select all'); });\n\n// any character (actual character inserted—triggered by the `keypress` event)\ncombokeys.bind('any-character', function () { console.log('some visual feedback') });\n\n// konami code!\ncombokeys.bind('up up down down left right left right b a enter', function() {\n    console.log('konami code');\n});\n```\n\nWhen you’re done with it, detach:\n\n```js\ncombokeys.detach()\n// and it will not listen on the element any more\n```\n\nYou can also bind the plus and minus keys conveniently:\n\n```js\ncombokeys.bind(['mod+plus', 'mod+minus'], function(e) {\n    e.preventDefault();\n    console.log(\"Override browser zoom!\");\n});\n```\n\n## Why Combokeys?\n\nThere are a number of other similar libraries out there so what makes this one different?\n\n- CommonJS, [NPM](https://www.npmjs.org/package/combokeys).\n- You can listen on multiple, specified elements simultaneously.\n- You are not limited to ``keydown`` events (You can specify ``keypress``, ``keydown``, or ``keyup`` or let Combokeys choose for you).\n- You can bind key events directly to special keys such as ``?`` or ``*`` without having to specify ``shift+/`` or ``shift+8`` which are not consistent across all keyboards\n- It works with international keyboard layouts\n- You can bind Gmail like key sequences in addition to regular keys and key combinations\n- You can programatically trigger key events with the ``trigger()`` method\n- It works with the numeric keypad on your keyboard\n- The code is well documented/commented\n\n### AMD usage\n\nYou can also build an AMD-compatible version by running `npm run build`. This creates a universally compatible ```dist/combokeys.js``` which, you can use via RequireJS, or include directly in a ```\u003cscript\u003e``` tag with the global variable ```Combokeys```.\n\n## Documentation\n\nThe most complete documentation is currently at [Mousetrap, the original project's website](http://craig.is/killing/mice). At the time of this writing, the only differences are in how you get it in your page (It is now a CommonJS module which does not define a global for itself) and that you must instantiate it before binding keys.\n\nThe public API consists of `.bind`, `.unbind`, `.trigger`, `.stopCallback`, `.detach` and `.reset`.\n\n## Plugins\n\nThere are [some plugins](https://github.com/avocode/combokeys/tree/master/plugins). See their individual readme files.\n\n### Bind dictionary\n\nAllows you to make multiple bindings in a single ``Combokeys.bind`` call.\n\n### Global bind\n\nAllows you to set global bindings that work even inside of input fields.\n\n### Pause/unpause\n\nAllows you to temporarily prevent Combokeys events from firing.\n\n### Record\n\nAllows you to capture a keyboard shortcut or sequence defined by a user.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favocode%2Fcombokeys","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Favocode%2Fcombokeys","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favocode%2Fcombokeys/lists"}