Shortcuts is a plugin for rails which gives you keyboard shortcuts.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
generators/shortcuts
lib
test
README
Rakefile
init.rb
uninstall.rb

README

=Shortcuts

Provides handling for keyboard shortcuts in javascript-enabled browsers.

Tested on Firefox, Safari, IE 6 and IE 7.


== Installation

Install with

  script/plugin install git://github.com/map7/shortcuts.git 

To prepare your application, run

  script/generate shortcuts
  
This will copy the necessary javscript file to the public/javascripts directory of the application.

Make sure you include either

  javascript_include_tag :defaults
  
or

  javascript_include_tag 'shortcuts'

somewhere in your HTML header.


First, make sure that the shortcuts helper is available to your views and helpers. Include it in application_helper.rb:

  module ApplicationHelper
    include ShortcutsHelper
    ...
  end


==Usage Examples


You can now use the helper methods in all your views:

To register a navigation shortcut:

  <%= shortcut 'p', projects_url %>
 
To register an ajax shortcut:

  <%= remote_shortcut 'd', delete_project_url(@project) %>

To register an arbitrary javascript function:

  <%= shortcut_function 'a', "alert('hello world');" %>

For details, refer to the inline documentation for ShortcutsHelper.

  <%= shortcut 'a', controller.controller_name + '/new' %>     <!-- New item for the current controller, could be put into application.html.erb -->

Control Key shortcuts
  <%= shortcut_ctrl 'b', '/' + controller.controller_name %>     
  <%= shortcut_ctrl_function 'a', 'alert("<Ctrl-a> pushed");' %> 

Function Keys
  <%= shortcut_fnkey_function '4', 'alert("F4 pressed");' %> 




==Running Tests

Sit in the plugins root directory and type 'rake'

This will run the unit tests in the test directory.