OLD | NEW |
1 <!-- BEGIN AUTHORED CONTENT --> | 1 <!-- BEGIN AUTHORED CONTENT --> |
2 <p> | 2 <p> |
3 The keybinding API allows you to add keyboard shortcuts that trigger actions in | 3 The commands API allows you to add keyboard shortcuts that trigger actions in |
4 your extension. An action can be opening the browser action or page action popup | 4 your extension. An action can be opening the browser action or page action popup |
5 or sending a command to the extension. | 5 or sending a command to the extension. |
6 </p> | 6 </p> |
7 | 7 |
8 <h2 id="manifest">Manifest</h2> | 8 <h2 id="manifest">Manifest</h2> |
9 <p> | 9 <p> |
10 In addition to the "experimental" permission you must declare the "keybinding" | 10 In addition to the "experimental" permission you must declare the "commands" |
11 permission in your extension's manifest to use this API and set manifest_version | 11 permission in your extension's manifest to use this API and set manifest_version |
12 to (at least) 2. | 12 to (at least) 2. |
13 </p> | 13 </p> |
14 | 14 |
15 <pre>{ | 15 <pre>{ |
16 "name": "My extension", | 16 "name": "My extension", |
17 ... | 17 ... |
18 <b> "permissions": [ | 18 <b> "permissions": [ |
19 "experimental", | 19 "experimental", |
20 "keybinding", | 20 "commands", |
21 ]</b>, | 21 ]</b>, |
22 ... | 22 ... |
23 }</pre> | 23 }</pre> |
24 | 24 |
25 <h2 id="usage">Usage</h2> | 25 <h2 id="usage">Usage</h2> |
26 <p>The keybinding API allows you to define specific commands, and bind them to a | 26 <p>The commands API allows you to define specific commands, and bind them to a |
27 default key combination. Each command your extension accepts must be listed in | 27 default key combination. Each command your extension accepts must be listed in |
28 the manifest as an attribute of the 'commands' manifest key. Note: Combinations | 28 the manifest as an attribute of the 'commands' manifest key. Note: Combinations |
29 that involve Ctrl+Alt are not permitted in order to avoid conflicts with the | 29 that involve Ctrl+Alt are not permitted in order to avoid conflicts with the |
30 AltGr key.</p> | 30 AltGr key.</p> |
31 | 31 |
32 <pre>{ | 32 <pre>{ |
33 "name": "My extension", | 33 "name": "My extension", |
34 ... | 34 ... |
35 <b> "commands": { | 35 <b> "commands": { |
36 "toggle-feature-foo": { | 36 "toggle-feature-foo": { |
(...skipping 20 matching lines...) Expand all Loading... |
57 } | 57 } |
58 }</b>, | 58 }</b>, |
59 ... | 59 ... |
60 }</pre> | 60 }</pre> |
61 | 61 |
62 <p>In your background page, you can bind a handler to each of the commands | 62 <p>In your background page, you can bind a handler to each of the commands |
63 defined in the manifest (except for '_execute_browser_action' and | 63 defined in the manifest (except for '_execute_browser_action' and |
64 '_execute_page_action') via onCommand.addListener. For example:</p> | 64 '_execute_page_action') via onCommand.addListener. For example:</p> |
65 | 65 |
66 <pre> | 66 <pre> |
67 chrome.experimental.keybinding.onCommand.addListener(function(command) { | 67 chrome.experimental.commands.onCommand.addListener(function(command) { |
68 console.log('Command:', command); | 68 console.log('Command:', command); |
69 }); | 69 }); |
70 </pre> | 70 </pre> |
71 | 71 |
72 <p>The '_execute_browser_action' and '_execute_page_action' commands are | 72 <p>The '_execute_browser_action' and '_execute_page_action' commands are |
73 reserved for the action of opening your extension's popups. They won't normally | 73 reserved for the action of opening your extension's popups. They won't normally |
74 generate events that you can handle. If you need to take action based on your | 74 generate events that you can handle. If you need to take action based on your |
75 popup opening, consider listening for an 'onDomReady' event inside your popup's | 75 popup opening, consider listening for an 'onDomReady' event inside your popup's |
76 code. | 76 code. |
77 </p> | 77 </p> |
78 <!-- END AUTHORED CONTENT --> | 78 <!-- END AUTHORED CONTENT --> |
OLD | NEW |