ten1seven / what-input

A global utility for tracking the current input method (mouse/pointer, keyboard or touch).
https://ten1seven.github.io/what-input
MIT License
1.35k stars 89 forks source link

fix: improve types #110

Closed mihkeleidast closed 4 years ago

mihkeleidast commented 4 years ago

Resolves #109.

This will allow importing of the additional types. For testing, this is now valid TS:

import whatInput, { InputMethod, Strategy } from 'what-input';

const handleInputChange = (type: InputMethod) => {
  console.log(type);
};
whatInput.registerOnChange(handleInputChange, 'intent');
whatInput.unRegisterOnChange(handleInputChange);

const getInputMethod = (strategy: Strategy) => {
  return whatInput.ask(strategy);
};
ten1seven commented 4 years ago

Thanks @mihkeleidast and @greypants! This has been published to NPM as version 5.2.10