{"id":13495266,"url":"https://github.com/jeresig/jquery.hotkeys","last_synced_at":"2025-03-28T16:32:03.415Z","repository":{"id":819128,"uuid":"531036","full_name":"jeresig/jquery.hotkeys","owner":"jeresig","description":"jQuery Hotkeys lets you watch for keyboard events anywhere in your code supporting almost any key combination.","archived":false,"fork":true,"pushed_at":"2021-10-22T08:45:50.000Z","size":282,"stargazers_count":2562,"open_issues_count":2,"forks_count":474,"subscribers_count":72,"default_branch":"master","last_synced_at":"2024-10-30T00:31:25.274Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"tzuryby/jquery.hotkeys","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jeresig.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-02-22T23:02:33.000Z","updated_at":"2024-10-25T09:42:56.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/jeresig/jquery.hotkeys","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeresig%2Fjquery.hotkeys","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeresig%2Fjquery.hotkeys/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeresig%2Fjquery.hotkeys/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeresig%2Fjquery.hotkeys/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jeresig","download_url":"https://codeload.github.com/jeresig/jquery.hotkeys/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222358376,"owners_count":16971562,"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":[],"created_at":"2024-07-31T19:01:33.044Z","updated_at":"2024-10-31T10:30:51.716Z","avatar_url":"https://github.com/jeresig.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","UI","Keyboard Wrappers","Keyboard Wrappers [🔝](#readme)","2. JavaScript 框架汇总","Web 前端","键盘封装器"],"sub_categories":["Runner","运行器","运行器e2e测试"],"readme":"# jQuery.Hotkeys [![Build Status](https://secure.travis-ci.org/jeresig/jquery.hotkeys.png)](http://travis-ci.org/jeresig/jquery.hotkeys)\n\n#About\n**jQuery Hotkeys** is a plug-in that lets you easily add and remove handlers for keyboard events anywhere in your code supporting almost any key combination.\n\nThis plugin is based off of the plugin by Tzury Bar Yochay: [jQuery.hotkeys](https://github.com/tzuryby/jquery.hotkeys)\n\nThe syntax is as follows:\n\n```javascript\n$(expression).bind(types, keys, handler);\n$(expression).unbind(types, handler);\n\n$(document).bind('keydown', 'ctrl+a', fn);\n\n// e.g. replace '$' sign with 'EUR'\n$('input.foo').bind('keyup', '$', function(){\n  this.value = this.value.replace('$', 'EUR');\n});\n```\n\nSyntax when wanting to use jQuery's `on()`/`off` methods:\n\n```javascript\n$(expression).on(types, null, keys, handler);\n$(expression).off(types, handler);\n\n$(document).on('keydown', null, 'ctrl+a', fn);\n\n// e.g. replace '$' sign with 'EUR'\n$('input.foo').on('keyup', null, '$', function(){\n  this.value = this.value.replace('$', 'EUR');\n});     \n```\n\n## Example\n\n[Example](https://rawgit.com/jeresig/jquery.hotkeys/master/test-static-01.html)\n\n## Event Types\n\nSupported types are `'keydown'`, `'keyup'` and `'keypress'`\n\n## jQuery Compatibility\n\nWorks with jQuery 1.4.2 and newer.\n\nIt is known to be working with all the major browsers on all available platforms (Win/Mac/Linux)\n\n * IE 6/7/8+\n * FF 1.5/2/3+\n * Opera-9+\n * Safari-3+\n * Chrome-0.2+\n\n## Browserify Compatibility\nIf you want to include this module in a Browserified project, just add it to node_modules and require it.\n```javascript\nrequire('jquery.javascript');\n```\n\nThis will work if jQuery is global (ex. served from a CDN). If it's not, you need to [shim it](https://github.com/thlorenz/browserify-shim#a-expose-global-variables-via-global):\n```javascript\n{\n  \"browserify-shim\": {\n    \"jquery\": \"global:jQuery\"\n  }\n}\n```\n\n## Notes\n\nModifiers are not case sensitive (`Ctrl` == `ctrl` == `cTRL`)\n\nIf you want to use more than one modifier (e.g. `alt+ctrl+z`) you should define them by an alphabetical order e.g. alt+ctrl+shift\n\nHotkeys aren't tracked if you're inside of an input element (unless you explicitly bind the hotkey directly to the input). This helps to avoid conflict with normal user typing.\n\nYou can use namespacing by adding a suffix to the event type (e.g. `keyup.toggle`)\n\n\n## Hotkeys within inputs\n\nHotkeys aren't tracked if the user is focused within an input element or any element that has `contenteditable=\"true\"` unless you bind the hotkey directly to the element. This helps to avoid conflict with normal user typing.\nIf you don't want this, you can change the booleans of the following to suit:\n\n * `jQuery.hotkeys.options.filterInputAcceptingElements`\n * `jQuery.hotkeys.options.filterContentEditable`\n * `jQuery.hotkeys.options.filterTextInputs` (deprecated, will be removed in a later version)\n\n### Meta and Hyper Keys\nMeta and hyper keys don't register on `keyup` in any browser tested.\n\n#### Chrome 33.0.1750.117\nMeta key registers on `keydown` event.\nHyper key registers on `keydown` event.\n\n#### Firefox 27.0.1 and Safari 7.0.1\nMeta key registers on `keydown` and `keypress` events.\nHyper key registers on `keydown` and `keypress` events.\n\n#### Opera 19.0\nMeta key doesn't register at all :(\nHyper key registers on `keydown` and `keypress` events.\n\n#### TL;DR\nBind to `keydown` event for meta and hyper keys, but meta key does not work in Opera ;)\n\n### Addendum\n\nFirefox is the most liberal one in the manner of letting you capture all short-cuts even those that are built-in in the browser such as `Ctrl-t` for new tab, or `Ctrl-a` for selecting all text. You can always bubble them up to the browser by returning `true` in your handler.\n\nOthers, (IE) either let you handle built-in short-cuts, but will add their functionality after your code has executed. Or (Opera/Safari) will *not* pass those events to the DOM at all.\n\n*So, if you bind `Ctrl-Q` or `Alt-F4` and your Safari/Opera window is closed don't be surprised.*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeresig%2Fjquery.hotkeys","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjeresig%2Fjquery.hotkeys","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeresig%2Fjquery.hotkeys/lists"}