Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(329)

Side by Side Diff: chrome/common/extensions/docs/static/experimental.keybinding.html

Issue 9812008: Polish the keybinding implementation a bit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 keybinding 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 "keybinding"
11 permission in your extension's manifest to use this API. 11 permission in your extension's manifest to use this API and set manifest_version
12 to (at least) 2.
12 </p> 13 </p>
13 14
14 <pre>{ 15 <pre>{
15 "name": "My extension", 16 "name": "My extension",
16 ... 17 ...
17 <b> "permissions": [ 18 <b> "permissions": [
18 "experimental", 19 "experimental",
19 "keybinding", 20 "keybinding",
20 ]</b>, 21 ]</b>,
21 ... 22 ...
22 }</pre> 23 }</pre>
23 24
24 <h2 id="usage">Usage</h2> 25 <h2 id="usage">Usage</h2>
25 <p>The keybinding API allows you to define specific commands, and bind them to a 26 <p>The keybinding API allows you to define specific commands, and bind them to a
26 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
27 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
28 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
29 AltGr key.</p> 30 AltGr key.</p>
30 31
31 <pre>{ 32 <pre>{
32 "name": "My extension", 33 "name": "My extension",
33 ... 34 ...
34 <b> "commands": { 35 <b> "commands": {
35 "toggle-feature-foo": { 36 "toggle-feature-foo": {
36 "key": "Ctrl+Shift+Y", 37 "suggested_key": {
38 "default": "Ctrl+Shift+Y",
39 "mac": "Command+Shift+Y"
40 },
37 "description": "Toggle feature foo" 41 "description": "Toggle feature foo"
38 }, 42 },
39 "browserAction": { 43 "_execute_browser_action": {
40 "key": "Ctrl+Shift+B" 44 "suggested_key": {
45 "windows": "Ctrl+Shift+Y",
46 "mac": "Command+Shift+Y",
47 "chromeos": "Ctrl+Shift+U",
48 "linux": "Ctrl+Shift+J"
49 }
41 }, 50 },
42 "pageAction": { 51 "_execute_page_action": {
43 "key": "Alt+P" 52 "suggested_key": {
53 "default": "Ctrl+E"
54 "windows": "Alt+P",
55 "mac": "Option+P",
56 }
44 } 57 }
45
46 }</b>, 58 }</b>,
47 ... 59 ...
48 }</pre> 60 }</pre>
49 61
50 <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
51 defined in the manifest (except for 'browserAction' and 'pageAction') via 63 defined in the manifest (except for '_execute_browser_action' and
52 onCommand.addListener. For example:</p> 64 '_execute_page_action') via onCommand.addListener. For example:</p>
53 65
54 <pre> 66 <pre>
55 chrome.experimental.keybinding.onCommand.addListener(function(command) { 67 chrome.experimental.keybinding.onCommand.addListener(function(command) {
56 console.log('Command:', command); 68 console.log('Command:', command);
57 }); 69 });
58 </pre> 70 </pre>
59 71
60 <p>The 'browserAction' and 'pageAction' commands are reserved for the action of 72 <p>The '_execute_browser_action' and '_execute_page_action' commands are
61 opening your extension's popups. They won't normally generate events that you 73 reserved for the action of opening your extension's popups. They won't normally
62 can handle. If you need to take action based on your popup opening, consider 74 generate events that you can handle. If you need to take action based on your
63 listening for an 'onDomReady' event inside your popup's code. 75 popup opening, consider listening for an 'onDomReady' event inside your popup's
76 code.
64 </p> 77 </p>
65 <!-- END AUTHORED CONTENT --> 78 <!-- END AUTHORED CONTENT -->
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/experimental.keybinding.html ('k') | chrome/common/extensions/extension.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698