Class YAHOO.ext.KeyMap
Package: | YAHOO.ext |
Class: | KeyMap |
Extends: | Object |
Defined In: | yutil.js |
Handles mapping keys to actions for an element. One key map can be used for multiple actions.
A KeyMap can also handle a string representation of keys.
Usage:
// map one key by key code
var map = new YAHOO.ext.KeyMap('my-element', {
key: 13,
fn: myHandler,
scope: myObject
});
// map multiple keys to one action by string
var map = new YAHOO.ext.KeyMap('my-element', {
key: "a\r\n\t",
fn: myHandler,
scope: myObject
});
// map multiple keys to multiple actions by strings and array of codes
var map = new YAHOO.ext.KeyMap('my-element', [
{
key: [10,13],
fn: function(){ alert('Return was pressed'); }
}, {
key: "abc",
fn: function(){ alert('a, b or c was pressed'); }
}, {
key: "\t",
ctrl:true,
shift:true,
fn: function(){ alert('Control + shift + tab was pressed.'); }
}
]);
Note: A KepMap starts enabled
Public Properties
This class has no public properties.
Public Methods
|
KeyMap(String/HTMLElement/YAHOO.ext.Element el , Object config , [String eventName ]) |
KeyMap |
|
|
addBinding(Object config ) : void |
KeyMap |
Add a new binding to this KeyMap |
|
disable() : void |
KeyMap |
Disable this KeyMap |
|
enable() : void |
KeyMap |
Enable this KeyMap |
|
isEnabled() : Boolean |
KeyMap |
Returns true if this KepMap is enabled |
Public Events
This class has no public events.
Constructor Details
KeyMap
public function KeyMap(String/HTMLElement/YAHOO.ext.Element el
, Object config
, [String eventName
])
Method Details
addBinding
public function addBinding(Object config
)
Add a new binding to this KeyMap
Parameters:
config
: ObjectA single KeyMap config
Returns:
This method is defined by KeyMap.
disable
public function disable()
This method is defined by KeyMap.
enable
public function enable()
This method is defined by KeyMap.
isEnabled
public function isEnabled()
Returns true if this KepMap is enabled
This method is defined by KeyMap.
yui-ext - Copyright © 2006 Jack Slocum. |
Yahoo! UI - Copyright © 2006 Yahoo! Inc.
All rights reserved.