[![AtlasKit component registry](https://img.shields.io/badge/AtlasKit-components-FF5230.svg)](http://aui-cdn.atlassian.com/atlaskit/registry/)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://Commitizen.github.io/cz-cli/)
[![semantic-release](https://img.shields.io/badge/GitHub-semantic_release-ffab00.svg)](https://github.com/semantic-release/semantic-release)
[![Report an issue](https://img.shields.io/badge/Report-an_issue-6554C0.svg)](https://ecosystem.atlassian.net/browse/AK)
[![Ask in our forum](https://img.shields.io/badge/Ask-in_our_forum-6554C0.svg)](https://answers.atlassian.com/questions/ask?title=AtlasKit%3A%20&topics=atlaskit,akutil-common,akutil-common@5.0.1)

# AtlasKit common utilities

A set of common utilities for all AtlasKit components

## Classes

<dl>
<dt><a href="#KeyPressHandler">KeyPressHandler</a></dt>
<dd><p>A general class to deal with key activations</p>
</dd>
</dl>

## Functions

<dl>
<dt><a href="#computeBooleanValue">computeBooleanValue()</a></dt>
<dd><p>Like el.hasAttribute(attr) but designed for use within a skate attribute
change handler where you only have access to change.oldValue.</p>
</dd>
<dt><a href="#enumeration">enumeration()</a></dt>
<dd><p>This property extension can be used with skate.
  Usage:</p>
<pre><code>  props: {
      respondsTo: props.enum({values: [&#39;toggle&#39;, &#39;hover&#39;],
      missingDefault: &#39;toggle&#39;,
      invalidDefault: &#39;toggle&#39;})({

      })
  }
</code></pre></dd>
</dl>

<a name="KeyPressHandler"></a>

## KeyPressHandler
A general class to deal with key activations

**Kind**: global class  
* Methods

    *  [keyPressHandler.add(key, callback)](#KeyPressHandler+add)
    *  [keyPressHandler.destroy([key])](#KeyPressHandler+destroy)

<a name="new_KeyPressHandler_new"></a>

### new KeyPressHandler(key, callback, [elem])
Adds a new keypress handler


| Param | Type | Description |
| --- | --- | --- |
| key | <code>String</code> | A named key. Case insensitive. |
| callback | <code>function</code> | A callback function to invoke if the given key was activated.                            The callback is passed the event object. |
| [elem] | <code>Node</code> | The element to listen for the key activation.                       Defaults to document if none given. |

<a name="KeyPressHandler+add"></a>

### keyPressHandler.add(key, callback)
Adds or replaces a key that is listened for.

**Kind**: instance method of <code>[KeyPressHandler](#KeyPressHandler)</code>  

| Param | Type | Description |
| --- | --- | --- |
| key | <code>String</code> | A named key. Case insensitive. Replaces any previous listened key. |
| callback | <code>function</code> | The callback function to invoke. |

<a name="KeyPressHandler+destroy"></a>

### keyPressHandler.destroy([key])
Removes a key from the list of listened keys.
Or removes the whole listener if no key given.

**Kind**: instance method of <code>[KeyPressHandler](#KeyPressHandler)</code>  

| Param | Type | Description |
| --- | --- | --- |
| [key] | <code>String</code> | A named key. Case insensitive. If none given, event listener is removed. |

<a name="computeBooleanValue"></a>

## computeBooleanValue()
Like el.hasAttribute(attr) but designed for use within a skate attribute
change handler where you only have access to change.oldValue.

**Kind**: global function  
<a name="enumeration"></a>

## enumeration()
This property extension can be used with skate.
  Usage:
  ```
  props: {
      respondsTo: props.enum({values: ['toggle', 'hover'],
      missingDefault: 'toggle',
      invalidDefault: 'toggle'})({

      })
  }
  ```

**Kind**: global function  

## Support and feedback

### We're here to help!

Let us know what you think of our components and docs, your feedback is really important for us.

### Community support

Ask a question in our [forum](https://answers.atlassian.com/questions/ask?title=AtlasKit%3A%20&topics=atlaskit,akutil-common,akutil-common@5.0.1).

Check [if someone has already asked the same question before](https://answers.atlassian.com/questions/topics/42926171/atlaskit).


### Create a support ticket

Are you in trouble? [Let us know](https://ecosystem.atlassian.net/browse/AK)!

