keyboard-actions

1.0.6ย โ€ขย Publicย โ€ขย Published

Keyboard Actions

Keyboard-actions is a package that allows devs to make their websites accessible from keyboard, which will give their users away better experience.

Just assign actions to keyboard buttons.

uses example

  • navigate slider throw arrow buttons
  • close popup using escape button
  • prevent default of the tab button etc....

Installing keyboard-actions

To install keyboard-actions, just run:

npm i keyboard-actions

Or use it via cdn

<script src="https://unpkg.com/keyboard-actions@latest"></script>

Documentation of keyboard-actions

pick the funcion you want to use.

import KeyboardActions from 'keyboard-actions';

const kb = new KeyboardActions();

// first show button names in console if you don't know its names
kb.showClickedButtonName();


// attach function to the key
kb.assignKeyAction('KeyName', (e) => console.log('assigned successfully ๐Ÿฅณ'))

// update key with new functions
kb.updateKeyAction('KeyName', (e) => console.log('key has 2๏ธโƒฃ functions now.'))

// reset the key to this only function
kb.setKeyAction('KeyName', (e) => console.log('it has just me now ๐Ÿ˜œ'))

// clean key from all functions assigned to it
kb.cleanKeyAction('KeyName') // ๐Ÿงน

// attach action to all keys
kb.assignDefaultActionToAllKeys((e) => console.log('i am every where ๐Ÿ™‹'))
// clean default actions
kb.cleanDefaultAction() // ๐Ÿงน


// prevent default for the button
kb.assignKeyAction("Tab", kb.prevent);



// switch on/off
kb.stop();    // stop the listeneing event
kb.start();   // start listening event

Contact

If you want to contact me you can reach me at mo.err17@gmail.com

License

This project uses the following license: MIT.

Package Sidebar

Install

npm i keyboard-actions

Weekly Downloads

6

Version

1.0.6

License

ISC

Unpacked Size

3.24 kB

Total Files

3

Last publish

Collaborators

  • mhmd17