Socket
Socket
Sign inDemoInstall

what-input

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

what-input

A global utility for tracking the current input method (mouse, keyboard or touch).


Version published
Weekly downloads
117K
decreased by-6.17%
Maintainers
1
Weekly downloads
 
Created

What is what-input?

The what-input npm package is a utility that helps you track the current input method (mouse, keyboard, touch, etc.) being used by the user. It can be particularly useful for improving accessibility and user experience by allowing developers to tailor interactions based on the input method.

What are what-input's main functionalities?

Detecting Input Method

This feature allows you to detect the current input method being used by the user. The `ask` method returns a string representing the input method, such as 'mouse', 'keyboard', or 'touch'.

const whatInput = require('what-input');

console.log(whatInput.ask()); // Logs the current input method, e.g., 'mouse', 'keyboard', 'touch'

Listening for Input Method Changes

This feature allows you to set up a listener that triggers a callback function whenever the input method changes. This can be useful for dynamically adjusting the user interface based on the input method.

const whatInput = require('what-input');

whatInput.onChange(function(method) {
  console.log('Input method changed to:', method);
});

Getting Specific Input Information

This feature provides additional information about the input methods and key codes that the library can detect. The `types` method returns an array of all possible input types, while the `keys` method returns an array of all possible key codes.

const whatInput = require('what-input');

console.log(whatInput.types()); // Logs an array of all possible input types
console.log(whatInput.keys()); // Logs an array of all possible key codes

Other packages similar to what-input

Keywords

FAQs

Package last updated on 25 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc