OLD | NEW |
1 <h2 id="manifest">Manifest</h2> | 1 <h2 id="manifest">Manifest</h2> |
2 <p> | 2 <p> |
3 You must set manifest_version to (at least) 2 to use this API. | 3 You must set manifest_version to (at least) 2 to use this API. |
4 </p> | 4 </p> |
5 | 5 |
6 <h2 id="usage">Usage</h2> | 6 <h2 id="usage">Usage</h2> |
7 <p>The commands API allows you to define specific commands, and bind them to a | 7 <p>The commands API allows you to define specific commands, and bind them to a |
8 default key combination. Each command your extension accepts must be listed in | 8 default key combination. Each command your extension accepts must be listed in |
9 the manifest as an attribute of the 'commands' manifest key. An extension can | 9 the manifest as an attribute of the 'commands' manifest key. An extension can |
10 have many commands but only 4 suggested keys can be specified. The user can | 10 have many commands but only 4 suggested keys can be specified. The user can |
(...skipping 26 matching lines...) Expand all Loading... |
37 "_execute_browser_action": { | 37 "_execute_browser_action": { |
38 "suggested_key": { | 38 "suggested_key": { |
39 "windows": "Ctrl+Shift+Y", | 39 "windows": "Ctrl+Shift+Y", |
40 "mac": "Command+Shift+Y", | 40 "mac": "Command+Shift+Y", |
41 "chromeos": "Ctrl+Shift+U", | 41 "chromeos": "Ctrl+Shift+U", |
42 "linux": "Ctrl+Shift+J" | 42 "linux": "Ctrl+Shift+J" |
43 } | 43 } |
44 }, | 44 }, |
45 "_execute_page_action": { | 45 "_execute_page_action": { |
46 "suggested_key": { | 46 "suggested_key": { |
47 "default": "Ctrl+E" | 47 "default": "Ctrl+E", |
48 "windows": "Alt+P", | 48 "windows": "Alt+P", |
49 "mac": "Option+P", | 49 "mac": "Option+P" |
50 } | 50 } |
51 } | 51 } |
52 }</b>, | 52 }</b>, |
53 ... | 53 ... |
54 }</pre> | 54 }</pre> |
55 | 55 |
56 <p>In your background page, you can bind a handler to each of the commands | 56 <p>In your background page, you can bind a handler to each of the commands |
57 defined in the manifest (except for '_execute_browser_action' and | 57 defined in the manifest (except for '_execute_browser_action' and |
58 '_execute_page_action') via onCommand.addListener. For example:</p> | 58 '_execute_page_action') via onCommand.addListener. For example:</p> |
59 | 59 |
60 <pre> | 60 <pre> |
61 chrome.commands.onCommand.addListener(function(command) { | 61 chrome.commands.onCommand.addListener(function(command) { |
62 console.log('Command:', command); | 62 console.log('Command:', command); |
63 }); | 63 }); |
64 </pre> | 64 </pre> |
65 | 65 |
66 <p>The '_execute_browser_action' and '_execute_page_action' commands are | 66 <p>The '_execute_browser_action' and '_execute_page_action' commands are |
67 reserved for the action of opening your extension's popups. They won't normally | 67 reserved for the action of opening your extension's popups. They won't normally |
68 generate events that you can handle. If you need to take action based on your | 68 generate events that you can handle. If you need to take action based on your |
69 popup opening, consider listening for an 'onDomReady' event inside your popup's | 69 popup opening, consider listening for an 'onDomReady' event inside your popup's |
70 code. | 70 code. |
71 </p> | 71 </p> |
OLD | NEW |