Makes numpad input consistent — even when NumLock is off. https://chrisgia.github.io/react-smart-numpad/
  • TypeScript 100%
Find a file
2025-10-11 17:55:44 +02:00
demo added demo 2025-10-11 17:53:37 +02:00
src added MIT LICENSE 2025-10-11 16:20:45 +02:00
.gitignore working package 2025-10-11 15:54:22 +02:00
LICENSE added MIT LICENSE 2025-10-11 16:20:45 +02:00
package-lock.json 1.0.6 2025-10-11 17:55:44 +02:00
package.json 1.0.6 2025-10-11 17:55:44 +02:00
README.md fix live demo URL 2025-10-11 17:55:38 +02:00
tsconfig.json working package 2025-10-11 15:54:22 +02:00

react-smart-numpad npm version License: MIT

Did it ever occur to you to have to type out numbers into some online form, and before realizing that your NumLock was disabled, the UI starts jumping around, switching to different input fields and everything gets messed up ?

Yeah, really annoying I know. This package fixes that.

Just think of it like a small UX enhancement to your existing UI.

Try it out: 🚀 Live Demo

Quick start

As a React hook:

import { useSmartNumpad } from 'react-smart-numpad';

const { value, onChange, onKeyDown } = useSmartNumpad();
<input value={value} onChange={onChange} onKeyDown={onKeyDown} />;

For more control, the handler can also be used directly:

import { handleSmartNumpadKeyDown } from 'react-smart-numpad';

const [value, setValue] = useState('');
<input onKeyDown={(e) => handleSmartNumpadKeyDown(e, setValue)} />;

Optional: Comma decimal separator

By default, the decimal character "." is used for the decimal separator right next to 0 on the NumPad. You can override this to use "," instead, by setting the option commaDecimal to true (used in most european countries).

Using the React Hook:

useSmartNumpad('<initial value>', { commaDecimal: true });

Using the handler directly:

onKeyDown={(e) =>
    handleSmartNumpadKeyDown(e, setValue, { commaDecimal: true })
}