OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html><!-- This page is a placeholder for generated extensions api doc.
Note: |
| 2 1) The <head> information in this page is significant, should be uniform |
| 3 across api docs and should be edited only with knowledge of the |
| 4 templating mechanism. |
| 5 3) All <body>.innerHTML is genereated as an rendering step. If viewed in a |
| 6 browser, it will be re-generated from the template, json schema and |
| 7 authored overview content. |
| 8 4) The <body>.innerHTML is also generated by an offline step so that this |
| 9 page may easily be indexed by search engines. |
| 10 --><html xmlns="http://www.w3.org/1999/xhtml"><head> |
| 11 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| 12 <link href="css/ApiRefStyles.css" rel="stylesheet" type="text/css"> |
| 13 <link href="css/print.css" rel="stylesheet" type="text/css" media="print"> |
| 14 <script type="text/javascript" src="../../../third_party/jstemplate/jstempla
te_compiled.js"> |
| 15 </script> |
| 16 <script type="text/javascript" src="js/api_page_generator.js"></script> |
| 17 <script type="text/javascript" src="js/bootstrap.js"></script> |
| 18 <script type="text/javascript" src="js/sidebar.js"></script> |
| 19 <meta name="description" content="Documentation for the chrome.experimental.ke
ybinding module, which is part of the Google Chrome extension APIs."><title>chr
ome.experimental.keybinding - Google Chrome Extensions - Google Code</title></he
ad> |
| 20 <body> <div id="devModeWarning" class="displayModeWarning"> |
| 21 You are viewing extension docs in chrome via the 'file:' scheme: are you exp
ecting to see local changes when you refresh? You'll need run chrome with --allo
w-file-access-from-files. |
| 22 </div> |
| 23 <div id="branchWarning" class="displayModeWarning"> |
| 24 <span>WARNING: This is the <span id="branchName">BETA</span> documentation. |
| 25 It may not work with the stable release of Chrome.</span> |
| 26 <select id="branchChooser"> |
| 27 <option>Choose a different version... |
| 28 </option><option value="">Stable |
| 29 </option><option value="beta">Beta |
| 30 </option><option value="dev">Dev |
| 31 </option><option value="trunk">Trunk |
| 32 </option></select> |
| 33 </div> |
| 34 <div id="unofficialWarning" class="displayModeWarning"> |
| 35 <span>WARNING: This is unofficial documentation. It may not work with the |
| 36 current release of Chrome.</span> |
| 37 <button id="goToOfficialDocs">Go to the official docs</button> |
| 38 </div> |
| 39 <div id="gc-container" class="labs"> |
| 40 <!-- SUBTEMPLATES: DO NOT MOVE FROM THIS LOCATION --> |
| 41 <!-- In particular, sub-templates that recurse, must be used by allowing |
| 42 jstemplate to make a copy of the template in this section which |
| 43 are not operated on by way of the jsskip="true" --> |
| 44 <!-- /SUBTEMPLATES --> |
| 45 <a id="top"></a> |
| 46 <div id="skipto"> |
| 47 <a href="#gc-pagecontent">Skip to page content</a> |
| 48 <a href="#gc-toc">Skip to main navigation</a> |
| 49 </div> |
| 50 <!-- API HEADER --> |
| 51 <table id="header" width="100%" cellspacing="0" border="0"> |
| 52 <tbody><tr> |
| 53 <td valign="middle"><a href="http://code.google.com/"><img src="images/c
ode_labs_logo.gif" height="43" width="161" alt="Google Code Labs" style="border:
0; margin:0;"></a></td> |
| 54 <td valign="middle" width="100%" style="padding-left:0.6em;"> |
| 55 <form action="http://www.google.com/cse" id="cse" style="margin-top:0.
5em"> |
| 56 <div id="gsc-search-box"> |
| 57 <input type="hidden" name="cx" value="002967670403910741006:61_cvz
fqtno"> |
| 58 <input type="hidden" name="ie" value="UTF-8"> |
| 59 <input type="text" name="q" value="" size="55"> |
| 60 <input class="gsc-search-button" type="submit" name="sa" value="Se
arch"> |
| 61 <br> |
| 62 <span class="greytext">e.g. "page action" or "tabs"</span> |
| 63 </div> |
| 64 </form> |
| 65 <script type="text/javascript" src="https://www.google.com/jsapi"></sc
ript> |
| 66 <script type="text/javascript">google.load("elements", "1", {packages:
"transliteration"});</script> |
| 67 <script type="text/javascript" src="https://www.google.com/coop/cse/t1
3n?form=cse&t13n_langs=en"></script> |
| 68 <script type="text/javascript" src="https://www.google.com/coop/cse/br
and?form=cse&lang=en"></script> |
| 69 </td> |
| 70 </tr> |
| 71 </tbody></table> |
| 72 <div id="codesiteContent" class=""> |
| 73 <a id="gc-topnav-anchor"></a> |
| 74 <div id="gc-topnav"> |
| 75 <h1>Google Chrome Extensions (<a href="http://code.google.com/labs/">Lab
s</a>)</h1> |
| 76 <ul id="home" class="gc-topnav-tabs"> |
| 77 <li id="home_link"> |
| 78 <a href="index.html" title="Google Chrome Extensions home page">Home
</a> |
| 79 </li> |
| 80 <li id="docs_link"> |
| 81 <a href="docs.html" title="Official Google Chrome Extensions documen
tation">Docs</a> |
| 82 </li> |
| 83 <li id="faq_link"> |
| 84 <a href="faq.html" title="Answers to frequently asked questions abou
t Google Chrome Extensions">FAQ</a> |
| 85 </li> |
| 86 <li id="samples_link"> |
| 87 <a href="samples.html" title="Sample extensions (with source code)">
Samples</a> |
| 88 </li> |
| 89 <li id="group_link"> |
| 90 <a href="http://groups.google.com/a/chromium.org/group/chromium-exte
nsions" title="Google Chrome Extensions developer forum">Group</a> |
| 91 </li> |
| 92 <li id="so_link"> |
| 93 <a href="http://stackoverflow.com/questions/tagged/google-chrome-ext
ension" title="[google-chrome-extension] tag on Stack Overflow">Questions?</a> |
| 94 </li> |
| 95 </ul> |
| 96 </div> <!-- end gc-topnav --> |
| 97 <div class="g-section g-tpl-170"> |
| 98 <!-- SIDENAV --> |
| 99 <div class="g-unit g-first" id="gc-toc"> |
| 100 <ul> |
| 101 <li><a href="getstarted.html">Getting Started</a></li> |
| 102 <li><a href="overview.html">Overview</a></li> |
| 103 <li><a href="whats_new.html">What's New?</a></li> |
| 104 <li><h2><a href="devguide.html">Developer's Guide</a></h2> |
| 105 <ul> |
| 106 <li>Browser UI |
| 107 <ul> |
| 108 <li><a href="browserAction.html">Browser Actions</a></li> |
| 109 <li><a href="contextMenus.html">Context Menus</a></li> |
| 110 <li><a href="notifications.html">Desktop Notifications</a></li
> |
| 111 <li><a href="omnibox.html">Omnibox</a></li> |
| 112 <li><a href="options.html">Options Pages</a></li> |
| 113 <li><a href="override.html">Override Pages</a></li> |
| 114 <li><a href="pageAction.html">Page Actions</a></li> |
| 115 </ul> |
| 116 </li> |
| 117 <li>Browser Interaction |
| 118 <ul> |
| 119 <li><a href="bookmarks.html">Bookmarks</a></li> |
| 120 <li><a href="cookies.html">Cookies</a></li> |
| 121 <li><a href="devtools.html">Developer Tools</a></li> |
| 122 <li><a href="events.html">Events</a></li> |
| 123 <li><a href="history.html">History</a></li> |
| 124 <li><a href="management.html">Management</a></li> |
| 125 <li><a href="tabs.html">Tabs</a></li> |
| 126 <li><a href="windows.html">Windows</a></li> |
| 127 </ul> |
| 128 </li> |
| 129 <li>Implementation |
| 130 <ul> |
| 131 <li><a href="a11y.html">Accessibility</a></li> |
| 132 <li><a href="background_pages.html">Background Pages</a></li> |
| 133 <li><a href="content_scripts.html">Content Scripts</a></li> |
| 134 <li><a href="xhr.html">Cross-Origin XHR</a></li> |
| 135 <li><a href="i18n.html">Internationalization</a></li> |
| 136 <li><a href="messaging.html">Message Passing</a></li> |
| 137 <li><a href="permissions.html">Optional Permissions</a></li> |
| 138 <li><a href="npapi.html">NPAPI Plugins</a></li> |
| 139 </ul> |
| 140 </li> |
| 141 <li>Finishing |
| 142 <ul> |
| 143 <li><a href="hosting.html">Hosting</a></li> |
| 144 <li><a href="external_extensions.html">Other Deployment Option
s</a></li> |
| 145 </ul> |
| 146 </li> |
| 147 </ul> |
| 148 </li> |
| 149 <li><h2><a href="apps.html">Packaged Apps</a></h2></li> |
| 150 <li><h2><a href="tutorials.html">Tutorials</a></h2> |
| 151 <ul> |
| 152 <li><a href="tut_debugging.html">Debugging</a></li> |
| 153 <li><a href="tut_analytics.html">Google Analytics</a></li> |
| 154 <li><a href="tut_oauth.html">OAuth</a></li> |
| 155 </ul> |
| 156 </li> |
| 157 <li><h2>Reference</h2> |
| 158 <ul> |
| 159 <li>Formats |
| 160 <ul> |
| 161 <li><a href="manifest.html">Manifest Files</a></li> |
| 162 <li><a href="match_patterns.html">Match Patterns</a></li> |
| 163 </ul> |
| 164 </li> |
| 165 <li><a href="permission_warnings.html">Permission Warnings</a></li
> |
| 166 <li><a href="api_index.html">chrome.* APIs</a></li> |
| 167 <li><a href="api_other.html">Other APIs</a></li> |
| 168 </ul> |
| 169 </li> |
| 170 <li><h2><a href="samples.html">Samples</a></h2></li> |
| 171 <div class="line"> </div> |
| 172 <li><h2>More</h2> |
| 173 <ul> |
| 174 <li><a href="http://code.google.com/chrome/webstore/docs/index.htm
l">Chrome Web Store</a></li> |
| 175 <li><a href="http://code.google.com/chrome/apps/docs/developers_gu
ide.html">Hosted Apps</a></li> |
| 176 <li><a href="themes.html">Themes</a></li> |
| 177 </ul> |
| 178 </li> |
| 179 </ul> |
| 180 </div> |
| 181 <script> |
| 182 initToggles(); |
| 183 </script> |
| 184 <div class="g-unit" id="gc-pagecontent"> |
| 185 <div id="pageTitle"> |
| 186 <h1 class="page_title">chrome.experimental.keybinding</h1> |
| 187 </div> |
| 188 <!-- TABLE OF CONTENTS --> |
| 189 <div id="toc"> |
| 190 <h2>Contents</h2> |
| 191 <ol> |
| 192 <li> |
| 193 <a href="#manifest">Manifest</a> |
| 194 <ol> |
| 195 </ol> |
| 196 </li><li> |
| 197 <a href="#usage">Usage</a> |
| 198 <ol> |
| 199 </ol> |
| 200 </li> |
| 201 <li> |
| 202 <a href="#apiReference">API reference: chrome.experimental.keybi
nding</a> |
| 203 <ol> |
| 204 <li> |
| 205 <a href="#global-events">Events</a> |
| 206 <ol> |
| 207 <li> |
| 208 <a href="#event-onCommand">onCommand</a> |
| 209 </li> |
| 210 </ol> |
| 211 </li> |
| 212 </ol> |
| 213 </li> |
| 214 </ol> |
| 215 </div> |
| 216 <!-- /TABLE OF CONTENTS --> |
| 217 <!-- Standard content lead-in for experimental API pages --> |
| 218 <p id="classSummary"> |
| 219 For information on how to use experimental APIs, see the <a href="expe
rimental.html">chrome.experimental.* APIs</a> page. |
| 220 </p> |
| 221 <!-- STATIC CONTENT PLACEHOLDER --> |
| 222 <div id="static"><!-- BEGIN AUTHORED CONTENT --> |
| 223 <p> |
| 224 The keybinding API allows you to add keyboard shortcuts that trigger actions in |
| 225 your extension. An action can be opening the browser action or page action popup |
| 226 or sending a command to the extension. |
| 227 </p> |
| 228 <h2 id="manifest">Manifest</h2> |
| 229 <p> |
| 230 In addition to the "experimental" permission you must declare the "keybinding" |
| 231 permission in your extension's manifest to use this API. |
| 232 </p> |
| 233 <pre>{ |
| 234 "name": "My extension", |
| 235 ... |
| 236 <b> "permissions": [ |
| 237 "experimental", "keybinding", |
| 238 ]</b>, |
| 239 ... |
| 240 }</pre> |
| 241 <h2 id="usage">Usage</h2> |
| 242 <p>The keybinding API allows you to define specific commands, and bind them to a |
| 243 default key combination. Each command your extension accepts must be listed in |
| 244 the manifest as an attribute of the 'commands' manifest key. Note: Combinations |
| 245 that involve Ctrl+Alt are not permitted in order to avoid conflicts with the |
| 246 AltGr key.</p> |
| 247 <pre>{ |
| 248 "name": "My extension", |
| 249 ... |
| 250 <b> "commands": { |
| 251 "toggle-feature-foo": { |
| 252 "key": "Ctrl+Shift+Y", |
| 253 "description": "Toggle feature foo" |
| 254 }, |
| 255 "browserAction": { |
| 256 "key": "Ctrl+Shift+B" |
| 257 }, |
| 258 "pageAction": { |
| 259 "key": "Alt+P" |
| 260 } |
| 261 }</b>, |
| 262 ... |
| 263 }</pre> |
| 264 <p>In your background page, you can bind a handler to each of the commands |
| 265 defined in the manifest (except for 'browserAction' and 'pageAction') via |
| 266 onCommand.addListener. For example:</p> |
| 267 <pre>chrome.experimental.keybinding.onCommand.addListener(function(command) { |
| 268 console.log('Command:', command); |
| 269 }); |
| 270 </pre> |
| 271 <p>The 'browserAction' and 'pageAction' commands are reserved for the action of |
| 272 opening your extension's popups. They won't normally generate events that you |
| 273 can handle. If you need to take action based on your popup opening, consider |
| 274 listening for an 'onDomReady' event inside your popup's code. |
| 275 </p> |
| 276 <!-- END AUTHORED CONTENT --> |
| 277 </div> |
| 278 <!-- API PAGE --> |
| 279 <div class="apiPage"> |
| 280 <a name="apiReference"></a> |
| 281 <h2>API reference: chrome.experimental.keybinding</h2> |
| 282 <!-- PROPERTIES --> |
| 283 <!-- /apiGroup --> |
| 284 <!-- METHODS --> |
| 285 <!-- /apiGroup --> |
| 286 <!-- EVENTS --> |
| 287 <div id="eventsTemplate" class="apiGroup"> |
| 288 <a name="global-events"></a> |
| 289 <h3>Events</h3> |
| 290 <!-- iterates over all events --> |
| 291 <div class="apiItem"> |
| 292 <a name="event-onCommand"></a> |
| 293 <h4>onCommand</h4> |
| 294 <div class="summary"> |
| 295 <!-- Note: intentionally longer 80 columns --> |
| 296 <span class="subdued">chrome.experimental.keybinding.</span><spa
n>onCommand</span><span class="subdued">.addListener</span>(function(<span>strin
g command</span>) <span class="subdued">{...}</span><span></span>); |
| 297 </div> |
| 298 <div class="description"> |
| 299 <p>Fired when a registered command is activated using a keyboard
shortcut.</p> |
| 300 <!-- LISTENER PARAMETERS --> |
| 301 <div> |
| 302 <h4>Listener parameters</h4> |
| 303 <dl> |
| 304 <div> |
| 305 <div> |
| 306 <dt> |
| 307 <var>command</var> |
| 308 <em> |
| 309 <!-- TYPE --> |
| 310 <div style="display:inline"> |
| 311 ( |
| 312 <span id="typeTemplate"> |
| 313 <span> |
| 314 <span>string</span> |
| 315 </span> |
| 316 </span> |
| 317 ) |
| 318 </div> |
| 319 </em> |
| 320 </dt> |
| 321 <dd class="todo"> |
| 322 Undocumented. |
| 323 </dd> |
| 324 <!-- OBJECT PROPERTIES --> |
| 325 <!-- OBJECT METHODS --> |
| 326 <!-- OBJECT EVENT FIELDS --> |
| 327 <!-- FUNCTION PARAMETERS --> |
| 328 </div> |
| 329 </div> |
| 330 </dl> |
| 331 </div> |
| 332 <!-- EXTRA PARAMETERS --> |
| 333 <!-- LISTENER RETURN VALUE --> |
| 334 <dl> |
| 335 </dl> |
| 336 </div> <!-- /description --> |
| 337 </div> <!-- /apiItem --> |
| 338 </div> <!-- /apiGroup --> |
| 339 <!-- TYPES --> |
| 340 <!-- /apiGroup --> |
| 341 </div> <!-- /apiPage --> |
| 342 </div> <!-- /gc-pagecontent --> |
| 343 </div> <!-- /g-section --> |
| 344 </div> <!-- /codesiteContent --> |
| 345 <div id="gc-footer" --=""> |
| 346 <div class="text"> |
| 347 <p> |
| 348 Except as otherwise <a href="http://code.google.com/policies.html#restrictions
">noted</a>, |
| 349 the content of this page is licensed under the <a rel="license" href="http://c
reativecommons.org/licenses/by/3.0/">Creative Commons |
| 350 Attribution 3.0 License</a>, and code samples are licensed under the |
| 351 <a rel="license" href="http://code.google.com/google_bsd_license.html">BSD Lic
ense</a>. |
| 352 </p> |
| 353 <p> |
| 354 ©2011 Google |
| 355 </p> |
| 356 <!-- begin analytics --> |
| 357 <script src="https://www.google-analytics.com/urchin.js" type="text/javascript">
</script> |
| 358 <script src="https://www.google-analytics.com/ga.js" type="text/javascript"></sc
ript> |
| 359 <script type="text/javascript"> |
| 360 // chrome doc tracking |
| 361 try { |
| 362 var engdocs = _gat._getTracker("YT-10763712-2"); |
| 363 engdocs._trackPageview(); |
| 364 } catch(err) {} |
| 365 // code.google.com site-wide tracking |
| 366 try { |
| 367 _uacct="UA-18071-1"; |
| 368 _uanchor=1; |
| 369 _uff=0; |
| 370 urchinTracker(); |
| 371 } |
| 372 catch(e) {/* urchinTracker not available. */} |
| 373 </script> |
| 374 <!-- end analytics --> |
| 375 </div> |
| 376 </div> <!-- /gc-footer --> |
| 377 </div> <!-- /gc-container --> |
| 378 </body></html> |
OLD | NEW |