Skip to content

Commit 288af23

Browse files
authored
Update README.md and added code in the key section
1 parent 6b66312 commit 288af23

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,13 +507,22 @@ if (keyCode === ENTER) {
507507
}
508508
```
509509

510-
Instead, in 2.x you can use the key function to directly compare the key value.
510+
Instead, in 2.x you can use the `key` or `code` function to directly compare the key value.
511+
512+
Using `key`:
511513
```js
512-
if (key === 'Enter') { // Enter key
514+
if (key === 'Enter') {
513515
// Code to run if the Enter key was pressed.
514516
}
515517
```
516518

519+
Using `code`:
520+
```js
521+
if (code === 'KeyA') {
522+
// Code to run if the 'A' key was pressed.
523+
}
524+
```
525+
517526
A more detailed comparison.
518527

519528
```js

0 commit comments

Comments
 (0)