]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Adjusted doc according to parameter change for Keyboard Util. 7579/head
authorMarius Olbertz <marius.olbertz@gmail.com>
Wed, 16 Dec 2015 16:28:41 +0000 (17:28 +0100)
committerMarius Olbertz <marius.olbertz@gmail.com>
Wed, 16 Dec 2015 16:28:41 +0000 (17:28 +0100)
Extended description if Keyboard Util.

docs/pages/javascript-utilities.md

index ef8c26a6a49350d243502763981375e7fcf146c6..b4e9171d0a0266aa8c7110421e1a086719bb27d4 100644 (file)
@@ -49,7 +49,8 @@ Another quite useful library, `Foundation.Keyboard` has several methods to make
 
 Ever wanted a handy list of common keycodes and the keys they represent? Use `Foundation.Keyboard.keys`. This is an object containing key/value pairs of the most frequently used keys in our framework.
 
-Want to manage your own keyboard inputs? No problem! Within your `.on('key**')` callback, call `Foundation.Keyboard.parseKey(event)` to get a string of what key was pressed, e.g. `'TAB'` or `'ALT_X'`.
+Want to manage your own keyboard inputs? No problem! Within your `.on('key**')` callback, call `Foundation.Keyboard.parseKey(event)` to get a string of what key was pressed, e.g. `'TAB'` or `'ALT_X'`. 
+You can also use this function outside of the Foundation components in your own JavaScript code.
 
 What if you want to know if there's focusable elements somewhere on a page? Instead of writing that function and selector yourself, just use:
 ```js
@@ -62,13 +63,15 @@ Foundation.Keyboard.register('pluginName', {
   'TAB': 'next'
 });
 ...//in event callback
-// `this` refers to the current plugin instance
-Foundation.Keyboard.handleKey(event, this, {
+Foundation.Keyboard.handleKey(event, 'pluginName', {
   next: function(){
     //do stuff
   }
 });
 ```
+There are also the functions `handled` and `unhandled` where you can place any code that shall always be executed after the key event has been handled or not.
+
+If you want to use your own key bindings, you can simply call the `Foundation.Keyboard.register` function even after Foundation has been initialized.
 
 ## MediaQuery
 `js/foundation.util.mediaQuery.js`