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

@daniel.husar/on-enter-or-space

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@daniel.husar/on-enter-or-space

Execure callback when enter or space is pressed

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by200%
Maintainers
1
Weekly downloads
 
Created
Source

on-enter-or-space

Execute function for enter and space keyboard events. This is usefull if you want to make your app accessible, and you want to add keyboard navigation to the components that have onClick handlers.

Install

Using npm

npm install @daniel.husar/on-enter-or-space

Using yarn

yarn add @daniel.husar/on-enter-or-space

Usage with react

First time you call onEnterOrSpace(callback) it will return another function, that accepts event object. If the event object was enter or space, it will call the callback with event object as parameter.

import onEnterOrSpace from '@daniel.husar/on-enter-or-space';
const component = (props) => {
  return <span onClick={props.handleOnClick} onKeyDown={onEnterOrSpace(props.handleOnClick)} />;
};

API

callback

Type: Function

Default: undefined

Required: true

Function you want to execute when enter or space event was passed in.

License

MIT © Daniel Husar

Keywords

FAQs

Package last updated on 09 Nov 2018

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