Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@three11/istouch

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@three11/istouch

Use JS to detect touch-enabled device

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

GitHub release GitHub issues GitHub last commit Build Status npm npm Analytics

isTouch

Use JS to detect touch-enabled device

Install

npm i @three11/istouch

or

yarn add @three11/istouch

Usage

import isTouch from '@three11/istouch';
import { setTouchClass } from '@three11/istouch';

console.log(isTouch); // Returns true for touch-enabled devices

setTouchClass(); // Set the default "touch" or "notouch" className to the `html` element

Customization

By default, the module sets a classname to the <html> tag. If the device is touch-enabled, the classname is touch. If not - the classname is no-touch.

You can overwrite these settings:

const el = document.getElementById('element');
const classNames = {
	touch: 'is-touch-device',
	notouch: 'is-not-touch-device'
};

setTouchClass(el, classNames);

License

MIT

Keywords

FAQs

Package last updated on 08 Dec 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