├── README.textile
├── demo.html
├── jquery.mapkey.js
└── jquery.mapkey.min.js
/README.textile:
--------------------------------------------------------------------------------
1 | h1. mapKey
2 |
3 | a plugin for jQuery
4 | *created by:* Josh Pyles / "Pixelmatrix Design":http://pixelmatrixdesign.com
5 | *license:* "MIT License":http://www.opensource.org/licenses/mit-license.php
6 |
7 | h2. Usage
8 |
9 | Fire the href of a link with rel of "next" when the right arrow key is pressed:
10 | @$("a[rel='next']").mapKey("right");@
11 |
12 | Fire a simple function when the down arrow key is pressed
13 | @$.mapKey("down", function(){
14 | $(".hiddendiv").slideDown();
15 | });@
16 |
17 | Fire a jQuery trigger when a key is pressed
18 | @$("div").mapKey("down", {trigger: facebox.show});@
19 |
20 | h2. Key shortcuts
21 |
22 | * You can use the keycodes if you want, but here are some helpful shortcut strings i've made:
23 | * All of the letter keys are available in their lowercase form (a-z)
24 | * Any of the numbers are available as themselves (0-9). This syntax specifies numpad & regular numerals
25 | * F1-F12 are lowercase: f1, f2, f3, etc
26 | * Numpad numbers are available as num1, num2, num3, etc
27 | * Regular numbers are available as top1, top2, top3, etc
28 | * Arrow keys available as left, right, up, and down
29 | * Backspace: "back"
30 | * Tab: "tab"
31 | * Enter: "enter"
32 | * Shift: "shift"
33 | * Control: "ctrl"
34 | * Alt/Option "alt" or "opt"
35 | * Pause: "pause"
36 | * Caps Lock: "caps"
37 | * Escape: "esc"
38 | * Space bar: "space"
39 | * Page up: "pgup"
40 | * Page down: "pgdown"
41 | * End: "end"
42 | * Home: "home"
43 | * Insert: "insert"
44 | * Delete: "del"
45 | * Windows key: "windows" (will target left or right windows buttons)
46 | * Command key: "cmd" (will target left or right command buttons) _same thing as windows key._
47 | * Left Windows key: "lwindows"
48 | * Right Windows key: "rwindwows"
49 | * Left Command key: "lcmd"
50 | * Right Command key: "rcmd"
51 | (Please note: doesn't matter if you use windows or command shortcut, it will work as windows in windows and command in mac)
52 | * Select: "select"
53 | * Numpad Multiply (asterisk): "multiply"
54 | * Numpad Add (+): "add"
55 | * Numpad Subtract: "subtract"
56 | * Numpad Decimal point: "decimalpt"
57 | * Numpad Divide (/): "divide"
58 | * Numlock: "numlock"
59 | * Scroll Lock: "scrolllock"
60 | * Semicolon: ";"
61 | * Equals: "="
62 | * Comma: ","
63 | * Hyphen/Dash: "-"
64 | * Period: "."
65 | * Slash: "/"
66 | * Accent: "`"
67 | * Open Bracket: "["
68 | * Close Bracket: "]"
69 | * Backslash (\): "backslash"
70 | * Single Quote ('): "singlequote"
71 |
72 | h2. Enable / Disable
73 |
74 | There may be times when you want the entire keyboard to be available for typing (such as forms). It's simple to enable or disable mapKey. Simply call @$.fn.mapKey.disable();@ and @$.fn.mapKey.enable();@ to enable it once again.
75 |
76 | h2. Direction parameter
77 |
78 | You have the option to fire events on keydown or keyup. Default is keyup. keydown gets fired multiple times if you hold down the button. That can be useful if you're using the arrow keys. Set the option when you call mapKey:
79 |
80 | @$.mapKey("left", function(){
81 | loadNextPage();
82 | }, {direction: "down"});@
83 |
84 | h2. More advanced stuff
85 |
86 | This plugin is meant to be a very light one. If you need to do more advanced things, I suggest trying jeresig's plugin "jQuery.hotkeys":http://github.com/jeresig/jquery.hotkeys. That can handle things like key combinations and more.
87 |
--------------------------------------------------------------------------------
/demo.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |