- *
-Handles mapping keys to actions for an element. One key map can be used for multiple actions.
-The constructor accepts the same config object as defined by
Handles mapping keys to actions for an element. One key map can be used for multiple actions.
+The constructor accepts the same config object as defined by
addBinding.
If you bind a callback function to a KeyMap, anytime the KeyMap handles an expected key
combination it will call the function with this signature (if the match is a multi-key
combination the callback will still be called only once): (String key, Ext.EventObject e)
A KeyMap can also handle a string representation of keys.
-Usage:
+Usage:
// map one key by key code
var map = new Ext.KeyMap("my-element", {
key: 13, // or Ext.EventObject.ENTER
@@ -50,83 +34,32 @@ Usage:
fn: function(){ alert('Control + shift + tab was pressed.'); }
}
]);
-
Note: A KeyMap starts enabled
-
-
-
-
Public Properties
-
-
-
-
-
-
- |
-
-
- stopEvent : Boolean
- True to stop the event from bubbling and prevent the default browser action if the
-key was handled by the KeyMap (def...
-
- True to stop the event from bubbling and prevent the default browser action if the
-key was handled by the KeyMap (defaults to false)
-
- |
- KeyMap |
-
-
-
-
Public Methods
-
-
-
-
-
-
- |
-
-
- KeyMap( Mixed el , Object config , [String eventName ] )
-
-
-
- Parameters:
-
- Returns:
-
-
-
-
- |
- KeyMap |
-
-
- |
-
-
- addBinding( Object/Array config ) : void
- Add a new binding to this KeyMap. The following config object properties are supported:
-Property Type ...
-
- Add a new binding to this KeyMap. The following config object properties are supported:
- Property Type Description
----------- --------------- ----------------------------------------------------------------------
-key String/Array A single keycode or an array of keycodes to handle
-shift Boolean True to handle key only when shift is pressed (defaults to false)
-ctrl Boolean True to handle key only when ctrl is pressed (defaults to false)
-alt Boolean True to handle key only when alt is pressed (defaults to false)
-handler Function The function to call when KeyMap finds the expected key combination
-fn Function Alias of handler (for backwards-compatibility)
-scope Object The scope of the callback function
-stopEvent Boolean True to stop the event
+ Note: A KeyMap starts enabledPublic Properties|
| stopEvent : BooleanTrue to stop the event from bubbling and prevent the default browser action if the
+key was handled by the KeyMap (def... True to stop the event from bubbling and prevent the default browser action if the
+key was handled by the KeyMap (defaults to false) | KeyMap |
Public Methods|
| KeyMap( Mixed el , Object config , [String eventName ] )
+ | KeyMap | | addBinding( Object/Array config )
+ :
+ voidAdd a new binding to this KeyMap. The following config object properties are supported:
+
+Property Type ... Add a new binding to this KeyMap. The following config object properties are supported:
+
+Property Type Description
+---------- --------------- ----------------------------------------------------------------------
+key String/Array A single keycode or an array of keycodes to handle
+shift Boolean True to handle key only when shift is pressed, False to handle the key only when shift is not pressed (defaults to undefined)
+ctrl Boolean True to handle key only when ctrl is pressed, False to handle the key only when ctrl is not pressed (defaults to undefined)
+alt Boolean True to handle key only when alt is pressed, False to handle the key only when alt is not pressed (defaults to undefined)
+handler Function The function to call when KeyMap finds the expected key combination
+fn Function Alias of handler (for backwards-compatibility)
+scope Object The scope of the callback function
+stopEvent Boolean True to stop the event from bubbling and prevent the default browser action if the key was handled by the KeyMap (defaults to false)
+
Usage:
// Create a KeyMap
var map = new Ext.KeyMap(document, {
key: Ext.EventObject.ENTER,
fn: handleKey,
- scope: this
+ scope: this
});
//Add a new binding to the existing KeyMap later
@@ -134,104 +67,17 @@ map.addBinding({
key: 'abc',
shift: true,
fn: handleKey,
- scope: this
-});
- Parameters:
-
- Returns:
-
-
-
-
- |
- KeyMap |
-
-
- |
-
-
- disable() : void
- Disable this KeyMap
-
- Disable this KeyMap
- Parameters:
-
- Returns:
-
-
-
-
- |
- KeyMap |
-
-
- |
-
-
- enable() : void
- Enables this KeyMap
-
- Enables this KeyMap
- Parameters:
-
- Returns:
-
-
-
-
- |
- KeyMap |
-
-
- |
-
-
- isEnabled() : Boolean
- Returns true if this KeyMap is enabled
-
- Returns true if this KeyMap is enabled
- Parameters:
-
- Returns:
-
-
-
-
- |
- KeyMap |
-
-
- |
-
-
- on( Number/Array/Object key , Function fn , [Object scope ] ) : void
- Shorthand for adding a single key listener
-
- Shorthand for adding a single key listener
- Parameters:
- key : Number/Array/ObjectEither the numeric key code, array of key codes or an object with the
+ scope: this
+});
| KeyMap | | disable()
+ :
+ void | KeyMap | | enable()
+ :
+ void | KeyMap | | isEnabled()
+ :
+ BooleanReturns true if this KeyMap is enabled Returns true if this KeyMap is enabled | KeyMap | | on( Number/Array/Object key , Function fn , [Object scope ] )
+ :
+ voidShorthand for adding a single key listener Shorthand for adding a single key listener Parameters:key : Number/Array/ObjectEither the numeric key code, array of key codes or an object with the
following options:
-{key: (number or array), shift: (true/false), ctrl: (true/false), alt: (true/false)} fn : FunctionThe function to call scope : Object(optional) The scope of the function
- Returns:
-
-
-
-
- |
- KeyMap |
-
-
-
- Public Events
- This class has no public events.
-
\ No newline at end of file
+{key: (number or array), shift: (true/false), ctrl: (true/false), alt: (true/false)}fn : FunctionThe function to call scope : Object(optional) The scope (this reference) in which the function is executed. Defaults to the browser window. Returns: | KeyMap |
| setDisabled( Boolean disabled )
+ :
+ voidConvenience function for setting disabled/enabled by boolean. Convenience function for setting disabled/enabled by boolean. | KeyMap |
Public Events
This class has no public events.