0.0.7 • Published 9 months ago

react-key-press-notice v0.0.7

Weekly downloads
-
License
-
Repository
github
Last release
9 months ago

React-key-press-notice

A simple React component to display the currently pressed key on the screen in real-time.

Key Press Gif

Feature

To prevent sensitive information from being displayed, you can use the enable prop to conditionally enable or disable the component based on specific use cases. Additionally, it can auto disable when a password input field is focused.

Installation

npm install react-key-press-notice

Usage

import KeyPressNotice from 'react-key-press-notice';

function App() {
  return <KeyPressNotice />;
}

export default App;

Example: Custom key emoji keyMap

<KeyPressNotice
  customKeyEmojiMap={{
    'Enter': '⏎',
    'Backspace': '⌫',
    'Tab': '⇥',
    'Space': '␣',
    'ArrowUp': '↑',
    'ArrowDown': '↓',
    'ArrowLeft': '←',
    'ArrowRight': '→',
  }}
/>

Props

Prop NameTypeDefaultOptionalDescription
topstring70%Yes ✅Top position of the key display
leftstring0Yes ✅Left position of the key display
containerStyleReact.CSSProperties{}Yes ✅Custom styles for the container element
containerClsstring""Yes ✅Custom class names for the container element
kbdStylesReact.CSSProperties{}Yes ✅Custom styles for the key display element
kbdClsstring""Yes ✅Custom class names for the key display element
showTimenumber500Yes ✅Duration (in milliseconds) to display the key
enablebooleanTRUEYes ✅Whether to enable the key display
customKeyEmojiMap{ key: string: string }{}Yes ✅Custom mapping of keys to emoji characters. This prop allows you to customize the emoji displayed for each key.

License:

MIT

Thanks

@YuanLiu