| OLD | NEW |
| 1 <table class="intro"> | 1 <table class="intro"> |
| 2 <tr> | 2 <tr> |
| 3 <th scope="col"></th> | 3 <th scope="col"></th> |
| 4 <th scope="col"></th> | 4 <th scope="col"></th> |
| 5 </tr> | 5 </tr> |
| 6 <tr> | 6 <tr> |
| 7 <td><strong>Description:</strong></td> | 7 <td><strong>Description:</strong></td> |
| 8 <td>Use the commands API to add keyboard shortcuts | 8 <td>Use the commands API to add keyboard shortcuts |
| 9 that trigger actions in your extension, | 9 that trigger actions in your extension, |
| 10 for example, an action to open the browser action | 10 for example, an action to open the browser action |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 </p> | 26 </p> |
| 27 | 27 |
| 28 <h2 id="usage">Usage</h2> | 28 <h2 id="usage">Usage</h2> |
| 29 <p>The commands API allows you to define specific commands, and bind them to a | 29 <p>The commands API allows you to define specific commands, and bind them to a |
| 30 default key combination. Each command your extension accepts must be listed in | 30 default key combination. Each command your extension accepts must be listed in |
| 31 the manifest as an attribute of the 'commands' manifest key. Note: Combinations | 31 the manifest as an attribute of the 'commands' manifest key. Note: Combinations |
| 32 that involve Ctrl+Alt are not permitted in order to avoid conflicts with the | 32 that involve Ctrl+Alt are not permitted in order to avoid conflicts with the |
| 33 AltGr key. Also note that on Mac 'Ctrl' is automatically converted to 'Command'. | 33 AltGr key. Also note that on Mac 'Ctrl' is automatically converted to 'Command'. |
| 34 If you want 'Ctrl' instead, please specify 'MacCtrl'.</p> | 34 If you want 'Ctrl' instead, please specify 'MacCtrl'.</p> |
| 35 | 35 |
| 36 <p>An extension can have many commands but only 4 suggested keys can be |
| 37 specified. The user can manually add more shortcuts from the chrome://extensions |
| 38 page.</p> |
| 39 |
| 36 <pre>{ | 40 <pre>{ |
| 37 "name": "My extension", | 41 "name": "My extension", |
| 38 ... | 42 ... |
| 39 <b> "commands": { | 43 <b> "commands": { |
| 40 "toggle-feature-foo": { | 44 "toggle-feature-foo": { |
| 41 "suggested_key": { | 45 "suggested_key": { |
| 42 "default": "Ctrl+Shift+Y", | 46 "default": "Ctrl+Shift+Y", |
| 43 "mac": "Command+Shift+Y" | 47 "mac": "Command+Shift+Y" |
| 44 }, | 48 }, |
| 45 "description": "Toggle feature foo" | 49 "description": "Toggle feature foo" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 72 console.log('Command:', command); | 76 console.log('Command:', command); |
| 73 }); | 77 }); |
| 74 </pre> | 78 </pre> |
| 75 | 79 |
| 76 <p>The '_execute_browser_action' and '_execute_page_action' commands are | 80 <p>The '_execute_browser_action' and '_execute_page_action' commands are |
| 77 reserved for the action of opening your extension's popups. They won't normally | 81 reserved for the action of opening your extension's popups. They won't normally |
| 78 generate events that you can handle. If you need to take action based on your | 82 generate events that you can handle. If you need to take action based on your |
| 79 popup opening, consider listening for an 'onDomReady' event inside your popup's | 83 popup opening, consider listening for an 'onDomReady' event inside your popup's |
| 80 code. | 84 code. |
| 81 </p> | 85 </p> |
| OLD | NEW |