{"id":18518368,"url":"https://github.com/javisperez/mousetrapdirectives","last_synced_at":"2026-04-30T13:33:35.994Z","repository":{"id":58230784,"uuid":"53789078","full_name":"javisperez/mousetrapdirectives","owner":"javisperez","description":"Some moustrap directives for angular","archived":false,"fork":false,"pushed_at":"2016-03-13T18:05:15.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-01-17T08:35:36.766Z","etag":null,"topics":["angular","angularjs","directives","keyboar-dshortcuts","mousetrap","mousetrap-directive","moustrap-focus","trigger"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/javisperez.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":"2016-03-13T14:24:07.000Z","updated_at":"2018-03-25T17:37:30.000Z","dependencies_parsed_at":"2022-08-31T00:31:15.473Z","dependency_job_id":null,"html_url":"https://github.com/javisperez/mousetrapdirectives","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/javisperez/mousetrapdirectives","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javisperez%2Fmousetrapdirectives","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javisperez%2Fmousetrapdirectives/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javisperez%2Fmousetrapdirectives/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javisperez%2Fmousetrapdirectives/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/javisperez","download_url":"https://codeload.github.com/javisperez/mousetrapdirectives/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javisperez%2Fmousetrapdirectives/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32466333,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"ssl_error","status_checked_at":"2026-04-30T13:12:06.837Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["angular","angularjs","directives","keyboar-dshortcuts","mousetrap","mousetrap-directive","moustrap-focus","trigger"],"created_at":"2024-11-06T17:13:08.522Z","updated_at":"2026-04-30T13:33:35.977Z","avatar_url":"https://github.com/javisperez.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mousetrap Directives\nSome moustrap directives for angularJS\n\n# What is this?\nThis repo has two angular directives useful when you need to have easy keyboard access to basic app actions. It depends on mousetrapJS for the keyboard shortcuts\n\n# About mousetrap\nThis module depends on [mousetrap](https://craig.is/killing/mice) which is a library for making keyboard shortcuts (and works great!). \n\nPlease check the [mousetrap documentation](https://craig.is/killing/mice) to see the posibilities of shortcuts combinations and more, i highly recommend it.\n\n# The directives\nSo far i've just done two directives:\n\n## mousetrap\nThe first directive is **mousetrap** which is a trigger of actions, based on keyboard shortcuts (as mousetrap works)\n\n## mousetrap-focus\nAnother directive is **mousetrap-focus** which (as the name says) it will focus on a given field by pressing a keyboard shortcut.\n\n# Install\nYou can use bower to install it:\n\n`bower install --save mousetrap-directives`\n\nOr you can download the zip on this repo and upload it to your server. Don't forget to include it in your html.\n\n# Usage\nJust include the module:\n\n`mousetrap-directives`\n\nin your angular app as dependency and bingo! you can use the directives.\n\n# Examples\nFirst, include it in your module:\n\n```javascript\nangular.module('app', ['mousetrap-directives']);\n```\n\n## mousetrap directive\nNow, to use the mousetrap directive, in the html just:\n\n```html\n\u003cspan mousetrap=\"{'o': open}\"\u003eOpen\u003c/span\u003e\n```\n\nOr you can just use a string, to trigger the click event (i.e. ng-click):\n\n```html\n\u003cbutton ng-click=\"alert()\" mousetrap=\"'c'\"\u003eClick me\u003c/button\u003e\n```\n\nthat would fire the alert function when the **c** key is press (by triggering the ng-click attribute)\n\n**Please notice** that if the tag is disabled, the moustrap actions wont fire, this is useful if you have a form that want to submit with keyboard only, but want to prevent disabled buttons to trigger anyway.\n\n## mousetrap-focus directive\n\nYou can focus on a field by using just the keyboard, like this:\n\n```html\n\u003cinput type=\"text\" ng-model=\"myModel\" class=\"mousetrap\" mousetrap-focus=\"'ctrl+b'\" /\u003e\n```\n\nWhen ctrl+b is pressed, the input will focus\n\n**Please notice** that [mousetrap](https://craig.is/killing/mice) disable the keyboard shortcuts on input fields by default, so, if you want to trigger the hotkey on an input you must add a **mousetrap** class.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjavisperez%2Fmousetrapdirectives","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjavisperez%2Fmousetrapdirectives","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjavisperez%2Fmousetrapdirectives/lists"}