Skip to content

Commit 19ff585

Browse files
continuazione traduzione
1 parent c364920 commit 19ff585

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

2-ui/3-event-details/7-keyboard-events/article.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -103,51 +103,51 @@ Se andiamo a controllare `event.code == 'KeyZ'` nel nostro codice, per gli utent
103103

104104
Questo può sembrare strano,ma è così. Le [specifiche](https://www.w3.org/TR/uievents-code/#table-key-code-alphanumeric-writing-system) menzionano in modo esplicito questo comportamento.
105105

106-
Quindi, `event.code` può corrispondere a un carattere errato da layout inaspettati. A parità di lettera, per layout differenti potrebbero essere mappati a tasti fisici differenti, portando a codici differenti. Fortunatamente, that happens only with several codes, e.g. `keyA`, `keyQ`, `keyZ` (as we've seen), and doesn't happen with special keys such as `Shift`. You can find the list in the [specification](https://www.w3.org/TR/uievents-code/#table-key-code-alphanumeric-writing-system).
106+
Quindi, `event.code` può corrispondere a un carattere errato da layout inaspettati. A parità di lettera, per layout differenti potrebbero essere mappati a tasti fisici differenti, portando a codici differenti. Fortunatamente, questo avviene solo con alcuni codici, ad esempio `keyA`, `keyQ`, `keyZ` (come abbiamo visto), e non avviene con i tasti speciali come `Shift`. Si può vedere la lista nelle [specifiche](https://www.w3.org/TR/uievents-code/#table-key-code-alphanumeric-writing-system).
107107

108-
To reliably track layout-dependent characters, `event.key` may be a better way.
108+
Per il tracciamento affidabile di carattere dipendenti dal layout, `event.key` potrebbe essere la soluzione migliore.
109109

110-
On the other hand, `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.
110+
D'altra parte, `event.code` ha il beneficio di essere sempre lo stesso, legato alla posizione fisica del tasto, anche se il visitatore dovesse modificare la lingua. Quindi le scorciatoie relative ad essi funzionano bene anche in caso di cambio lingua.
111111

112-
Do we want to handle layout-dependant keys? Then `event.key` is the way to go.
112+
Vogliamo gestire dei tasti dipendenti dal layout? Allora `event.key` è la quello che fa per noi.
113113

114-
Or we want a hotkey to work even after a language switch? Then `event.code` may be better.
114+
Oppure volgiamo una scorciatoia che funzioni anche al cambio lingua? Allora `event.code` potrebbe essere meglio.
115115

116116
## Auto-repeat
117117

118-
If a key is being pressed for a long enough time, it starts to "auto-repeat": the `keydown` triggers again and again, and then when it's released we finally get `keyup`. So it's kind of normal to have many `keydown` and a single `keyup`.
118+
Se un tasto viene premuto abbastanza a lungo, comincia l'"auto-repeat": l'evento `keydown` viene scaturito ancora e ancora, e alla fine quando verrà rilasciato otterremo un evento `keyup`. Quindi è abbastanza normale avere molti `keydown` e un solo `keyup`.
119119

120-
For events triggered by auto-repeat, the event object has `event.repeat` property set to `true`.
120+
Per eventi generati da auto-repeat, l'oggetto evento ha la proprietà `event.repeat` impostata a `true`.
121121

122122

123-
## Default actions
123+
## Azioni default
124124

125-
Default actions vary, as there are many possible things that may be initiated by the keyboard.
125+
Le azioni di default possono variare, dal momento che sono tante le cose che possono essere iniziate con la tastiera.
126126

127-
For instance:
127+
Per esempio:
128128

129-
- A character appears on the screen (the most obvious outcome).
130-
- A character is deleted (`key:Delete` key).
131-
- The page is scrolled (`key:PageDown` key).
132-
- The browser opens the "Save Page" dialog (`key:Ctrl+S`)
133-
- ...and so on.
129+
- Compare un carattere sullo schermo (lo scenario più ovvio).
130+
- Viene cancellato un carattere (tasto `key:Delete`).
131+
- Si scrolla la pagina (tasto `key:PageDown`).
132+
- Il browser apre la finestra di dialogo "Sala la Pagina" (`key:Ctrl+S`)
133+
- ...e così via.
134134

135-
Preventing the default action on `keydown` can cancel most of them, with the exception of OS-based special keys. For instance, on Windows `key:Alt+F4` closes the current browser window. And there's no way to stop it by preventing the default action in JavaScript.
135+
Prevenire le azioni di default sul `keydown` può annullare la maggioranza di essere, con l'eccezione delle combinazioni di tasti del sistema operativo. Per esempio, su Windows `key:Alt+F4` chiude la finestra attuale del browser. E non c'è modo per prevenire questa azione predefinita tramite JavaScript.
136136

137-
For instance, the `<input>` below expects a phone number, so it does not accept keys except digits, `+`, `()` or `-`:
137+
Per esempio, il seguene campo `<input>` si aspetta un numero di telefono, quindi nn accetta tasti che non siano numeri, `+`, `()` or `-`:
138138

139139
```html autorun height=60 run
140140
<script>
141141
function checkPhoneKey(key) {
142142
return (key >= '0' && key <= '9') || key == '+' || key == '(' || key == ')' || key == '-';
143143
}
144144
</script>
145-
<input *!*onkeydown="return checkPhoneKey(event.key)"*/!* placeholder="Phone, please" type="tel">
145+
<input *!*onkeydown="return checkPhoneKey(event.key)"*/!* placeholder="Numero di telefono, per piacere" type="tel">
146146
```
147147

148-
Please note that special keys, such as `key:Backspace`, `key:Left`, `key:Right`, `key:Ctrl+V`, do not work in the input. That's a side-effect of the strict filter `checkPhoneKey`.
148+
È interessante notare che i tasti speciali, come `key:Backspace`, `key:Left`, `key:Right`, `key:Ctrl+V`, non funzionano nel campo input. Questo è un effetto collaterale delle restrizioni del filtro `checkPhoneKey`.
149149

150-
Let's relax it a little bit:
150+
Facciamolo "rilassare" un attimo:
151151

152152

153153
```html autorun height=60 run
@@ -160,19 +160,19 @@ function checkPhoneKey(key) {
160160
<input onkeydown="return checkPhoneKey(event.key)" placeholder="Phone, please" type="tel">
161161
```
162162

163-
Now arrows and deletion works well.
163+
Adesso le frecce e il tasto cancella funzionano.
164164

165-
...But we still can enter anything by using a mouse and right-click + Paste. So the filter is not 100% reliable. We can just let it be like that, because most of time it works. Or an alternative approach would be to track the `input` event -- it triggers after any modification. There we can check the new value and highlight/modify it when it's invalid.
165+
...Ma possiamo ancora inserire qualunque valore usando il mouse e facendo tasto destro + Incolla. Quindi il filtro non è al 100% affidabile. Possiamo solo lasciarlo così, dato che funzionerà la maggior parte delle volte. O un approccio alternativo potrebbe essere quello di tenere traccia dell'evento `input`, che viene scaturito dopo ogni modifica. A quel punto, possiamo verificare il nuovo valore e evidenziarlo/modificarlo se non valido.
166166

167-
## Legacy
167+
## Eredità
168168

169-
In the past, there was a `keypress` event, and also `keyCode`, `charCode`, `which` properties of the event object.
169+
Nel passato, c'era un evento `keypress`, ed anche le proprietà `keyCode`, `charCode`, `which` dell'oggetto evento.
170170

171-
There were so many browser incompatibilities while working with them, that developers of the specification had no way, other than deprecating all of them and creating new, modern events (described above in this chapter). The old code still works, as browsers keep supporting them, but there's totally no need to use those any more.
171+
C'erano tante di quelle incompatibilità tra i vari browser anche mentre ci stavano lavorando, che gli sviluppatori delle specifiche non avevano modo che deprecarli tutti e creare dei nuovi e moderni eventi (descritti sopra in questo capitolo). Il codice vecchio funziona ancora, da momento che i broweser continuano a supportarli, ma assolutamente non c'è nessuna ragione per continuare a farlo.
172172

173-
## Mobile Keyboards
173+
## Tastiere dei dispositivi mobile
174174

175-
When using virtual/mobile keyboards, formally known as IME (Input-Method Editor), the W3C standard states that a KeyboardEvent's [`e.keyCode` should be `229`](https://www.w3.org/TR/uievents/#determine-keydown-keyup-keyCode) and [`e.key` should be `"Unidentified"`](https://www.w3.org/TR/uievents-key/#key-attr-values).
175+
Usando le tastiere virtuali dei dispositivi mobile, conosciute formalmente come IME (Input-Method Editor), the W3C standard states that a KeyboardEvent's [`e.keyCode` should be `229`](https://www.w3.org/TR/uievents/#determine-keydown-keyup-keyCode) and [`e.key` should be `"Unidentified"`](https://www.w3.org/TR/uievents-key/#key-attr-values).
176176

177177
While some of these keyboards might still use the right values for `e.key`, `e.code`, `e.keyCode`... when pressing certain keys such as arrows or backspace, there's no guarantee, so your keyboard logic might not always work on mobile devices.
178178

0 commit comments

Comments
 (0)