@timeyurah/handle-key-press

1.0.2 • Public • Published

@timeyurah/handle-key-press

npm (scoped)

Objetivo

Checar qual tecla foi digitada pelo usuário. Caso a tecla seja a escolhida, executar uma função.

Instalação

npm install @timeyurah/handle-key-press

Uso

Em um ambiente React:

import React, { Component } from 'react;
import handleKeyPress from '@timeyurah/handle-key-press';

class Test extends Component {
  testFunction = () => {
    console.log('It worked!')
  }

  render = () =>
    <form>
      <input type='text' onKeyPress={ e => handleKeyPress(e, 'Enter', this.testFunction) } />
    </form>
}

export default Test;

Readme

Keywords

none

Package Sidebar

Install

npm i @timeyurah/handle-key-press

Weekly Downloads

4

Version

1.0.2

License

MIT

Unpacked Size

1.4 kB

Total Files

4

Last publish

Collaborators

  • delucca
  • victorperin