Search results

KeyboardEvents API in JavaScript (ES5) Base API control

KeyboardEvents class enables you to bind key action desired key combinations for ex., Ctrl+A, Delete, Alt+Space etc.

<div id='testEle'>  </div>;
<script>
  let node: HTMLElement = document.querySelector('#testEle');
  let kbInstance = new KeyboardEvents({
      element: node,
      keyConfigs:{ selectAll : 'ctrl+a' },
      keyAction: function (e:KeyboardEvent, action:string) {
          // handler function code
      }
  });
</script>

Properties

eventName

string

Specifies on which event keyboardEvents class should listen for key press. For ex., keyup, keydown or keypress

Defaults to keyup

keyConfigs

{ [key: string]: string }

Specifies key combination and it respective action name.

Defaults to null

Methods

addEventListener

Adds the handler to the given event listener.

Parameter Type Description
eventName string A String that specifies the name of the event
handler Function Specifies the call to run when the event occurs.

Returns void

dataBind

Bind property changes immediately to components

Returns void

destroy

Unwire bound events and destroy the instance.

Returns void

removeEventListener

Removes the handler from the given event listener.

Parameter Type Description
eventName string A String that specifies the name of the event to remove
handler Function Specifies the function to remove

Returns void

Events

keyAction

EmitType<KeyboardEventArgs>

Specifies the listener when keyboard actions is performed.