Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Rails gem for handling keyboard shortcuts via mousetrap javascript library
Ruby CSS HTML CoffeeScript JavaScript

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
vendor/assets/javascripts
.gitignore
CHANGELOG.md
Gemfile
LICENSE.txt
README.md
Rakefile
mousetrap-rails.gemspec

README.md

Mousetrap::Rails

Moustrap is a javascript library for handling keyboard shortcuts in your web applications written by Craig Campbell.

The mousetrap-rails gem integrates Moustrap javascript library with Rails Asset Pipeline.

Installation

Install mousetrap-rails gem

Add this line to your application's Gemfile:

gem 'mousetrap-rails'

And then execute:

$ bundle install

Include moustrap to asset pipeline

Add to your app/assets/javascripts/application.js file

//= require mousetrap

Voila!

Usage

Now you can use Moustrap library features in your rails application. To test it out create coffeescript file in your app/assets/javascripts directory and add to it this code

# app/assets/javascripts/test_hotkeys.js.coffee
Mousetrap.bind 's', -> console.log 's pressed!'

Run application and press s on your keyboard. You should see s pressed! message in your javascript console.

You can find full documentation on Moustrap library page. Really, look there – there are plenty examples of using this awesome library.

Authors

Something went wrong with that request. Please try again.