Skip to content

Commit 1713c4f

Browse files
committed
Add support for +, * and numeric keys on numpad
1 parent cbf13a9 commit 1713c4f

File tree

7 files changed

+17640
-13237
lines changed

7 files changed

+17640
-13237
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ npm install react-keyboard-event-handler
2929
By default, `KeyboardEventHandler` only handles global key events sourced from `document.body`.
3030
That is, key events fired without any focused element (`event.target`). It will not
3131
handle key events sourced from form controls (e.g. input ), links or any
32-
tab-enabled(focusable) elements (e.g. elements with `tabIndex` attribute).
32+
tab-enabled(focusable) elements (e.g. elements with `tabIndex` attribute).
3333

3434
Web browsers come with default keyboard behaviors for tab-enabled elements. It may be desirable
3535
to let the browser do its job in most cases.
@@ -79,8 +79,8 @@ handleKeys| Array | [] |An array of keys this handler should handle. <br/> There
7979
handleEventType| String | keydown |Keyboard event type. <br />This can be 'keyup', 'keydown' or 'keypress'. <br /><sup>*</sup>**Note**: 'keypress' event only support printable keys. i.e. no support for modifier keys or 'tab', 'enter' etc.
8080
handleFocusableElements| Bool | false | By default, handler only handles key events sourced from `doucment.body`. When this props is set to `true`, it will also handle key events from all focusable elements. This props only apply when there's no children.
8181
isDisabled| Boolean | false |Enable/Disable handling keyboard events
82-
isExclusive| Boolean | false |When set to `true`, all other handler instances are suspended. <br />This is useful for temporary disabling all other keyboard event handlers. <br />For example, suppressing any other handlers on a page when a modal opens with its own keyboard event handling.
83-
onKeyEvent| function | `() => null` | <p>A callback function to call when the handler detects a matched key event.</p><p>The signature of the callback function is: <br />`function(key, event) { ... }`<p><dl><dh>`key`</dh><dd>The key string as one of the elements in `HandleKeys` props that matches the current keyboard event. <br />If alias key name is used, it will be the lowercase key name (see bellow) matching the event.</dd><dh>`event`</dh><dd>The native [keyboard event](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent). e.g. you can use `event.keyCode` to get the numeric key code.</dd></dl>
82+
isExclusive| Boolean | false |When set to `true`, all other handler instances are suspended. <br />This is useful for temporary disabling all other keyboard event handlers. <br />For example, suppressing any other handlers on a page when a modal opens with its own keyboard event handling.
83+
onKeyEvent| function | `() => null` | <p>A callback function to call when the handler detects a matched key event.</p><p>The signature of the callback function is: <br />`function(key, event) { ... }`<p><dl><dh>`key`</dh><dd>The key string as one of the elements in `HandleKeys` props that matches the current keyboard event. <br />If alias key name is used, it will be the lowercase key name (see bellow) matching the event.</dd><dh>`event`</dh><dd>The native [keyboard event](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent). e.g. you can use `event.keyCode` to get the numeric key code.</dd></dl>
8484
children| Any | null | If `KeyboardEventHandler` wraps around any children elements, it will handle and ONLY handle key events sourced from its descendant elements, including any form controls, links or tab-enabled elements. `handleFocusableElements` has no effect when `children` exists.
8585

8686
# Key names and key alias
@@ -113,7 +113,7 @@ You can handle one of more common keys by using an array of their names.
113113
Key name|Description / key code
114114
---|---
115115
a, b, ... z | letter keys, 65 ~ 90
116-
0, 1, ... 9 | number keys 48 ~ 57
116+
0, 1, ... 9 | number keys 48 ~ 57 and 96 ~ 105
117117
backspace|8
118118
del/delete| 46
119119
tab| 9

0 commit comments

Comments
 (0)