fixes
This commit is contained in:
parent
f8f3c948a4
commit
f8570ae3a0
2 changed files with 5 additions and 5 deletions
|
@ -453,7 +453,7 @@ let wrapper = function() {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
We also saw an example of *method borrowing* when we take a method from an object and `call` it in the context of another object. It is quite common to take array methods and apply them to arguments. The alternative is to use rest parameters object that is a real array.
|
We also saw an example of *method borrowing* when we take a method from an object and `call` it in the context of another object. It is quite common to take array methods and apply them to `arguments`. The alternative is to use rest parameters object that is a real array.
|
||||||
|
|
||||||
|
|
||||||
There are many decorators there in the wild. Check how well you got them by solving the tasks of this chapter.
|
There are many decorators there in the wild. Check how well you got them by solving the tasks of this chapter.
|
||||||
|
|
|
@ -97,14 +97,14 @@ For example, here are US layout ("QWERTY") and German layout ("QWERTZ") under it
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
For the same key, US layout has "Z", while German layout has "Y" and (letters are swapped).
|
For the same key, US layout has "Z", while German layout has "Y" (letters are swapped).
|
||||||
|
|
||||||
So, `event.code` will equal `KeyZ` for German people who press "Y". Just because the keyboard layout is different.
|
So, `event.code` will equal `KeyZ` for people with German layout when they press "Y".
|
||||||
|
|
||||||
That sounds odd, but so it is. The [specification](https://www.w3.org/TR/uievents-code/#table-key-code-alphanumeric-writing-system) explicitly mentions such behavior.
|
That sounds odd, but so it is. The [specification](https://www.w3.org/TR/uievents-code/#table-key-code-alphanumeric-writing-system) explicitly mentions such behavior.
|
||||||
|
|
||||||
- `event.code` has the benefit of being the same, even if the visitor changes languages. So hotkeys that rely on it work well even in case of a language switch.
|
- `event.code` has the benefit of staying always the same, bound to the physical key location, even if the visitor changes languages. So hotkeys that rely on it work well even in case of a language switch.
|
||||||
- `event.code` may match a wrong character for unexpected layout. Same letters in different layouts may be at different keyboard keys, leading to different codes. That happens for several codes, e.g. `keyA`, `keyQ`, `keyZ`. You can find the list in the [specification](https://www.w3.org/TR/uievents-code/#table-key-code-alphanumeric-writing-system).
|
- `event.code` may match a wrong character for unexpected layout. Same letters in different layouts may map to different physical keys, leading to different codes. That happens for several codes, e.g. `keyA`, `keyQ`, `keyZ` (as we've seen). You can find the list in the [specification](https://www.w3.org/TR/uievents-code/#table-key-code-alphanumeric-writing-system).
|
||||||
|
|
||||||
So, to reliably track layout-dependent characters, `event.key` may be a better way.
|
So, to reliably track layout-dependent characters, `event.key` may be a better way.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue