We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6b66312 commit 288af23Copy full SHA for 288af23
README.md
@@ -507,13 +507,22 @@ if (keyCode === ENTER) {
507
}
508
```
509
510
-Instead, in 2.x you can use the key function to directly compare the key value.
+Instead, in 2.x you can use the `key` or `code` function to directly compare the key value.
511
+
512
+Using `key`:
513
```js
-if (key === 'Enter') { // Enter key
514
+if (key === 'Enter') {
515
// Code to run if the Enter key was pressed.
516
517
518
519
+Using `code`:
520
+```js
521
+if (code === 'KeyA') {
522
+ // Code to run if the 'A' key was pressed.
523
+}
524
+```
525
526
A more detailed comparison.
527
528
0 commit comments