L'event "keydown" s'active plusieurs fois
Résolu/Fermé
Hibou-Propulseur
Messages postés
3
Date d'inscription
lundi 26 juillet 2021
Statut
Membre
Dernière intervention
22 août 2021
-
Modifié le 26 juil. 2021 à 18:25
kaneagle Messages postés 84431 Date d'inscription mercredi 27 mai 2009 Statut Modérateur Dernière intervention 28 mai 2023 - 22 août 2021 à 14:25
kaneagle Messages postés 84431 Date d'inscription mercredi 27 mai 2009 Statut Modérateur Dernière intervention 28 mai 2023 - 22 août 2021 à 14:25
A voir également:
- L'event "keydown" s'active plusieurs fois
- Sport event 365 avis ✓ - Forum Consommation et internet
- Qu'est ce qu'une femme fait 3 fois par jour - Forum Loisirs / Divertissements
- Pass telecommande active - Forum Téléviseurs
- Site paiement plusieur fois carte nickel forum - Forum Consommation et internet
- Safesearch reste activé - Forum Internet / Réseaux sociaux
2 réponses
Hibou-Propulseur
Messages postés
3
Date d'inscription
lundi 26 juillet 2021
Statut
Membre
Dernière intervention
22 août 2021
Modifié le 26 juil. 2021 à 18:34
Modifié le 26 juil. 2021 à 18:34
Ok j'ai trouvé une réponse... (https://javascript.info/keyboard-events)
Auto-repeat
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.
For events triggered by auto-repeat, the event object has event.repeat property set to true.
donc ça donne :
EDIT: Comment on fait pour clore ce sujet ?
Auto-repeat
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.
For events triggered by auto-repeat, the event object has event.repeat property set to true.
donc ça donne :
document.addEventListener("keydown", function(e) { console.log("keydown"); for(var k in dict) { if (e.keyCode == k) { if (e.repeat != true){// petite modif ici ! console.log("touche n°: "+k+" appuyée"); function modif(){ dict[k](); refresh(); } modif(); dictIntervalles[k] = setInterval(modif,1000/nbDePasParSec); } } } });
EDIT: Comment on fait pour clore ce sujet ?
kaneagle
Messages postés
84431
Date d'inscription
mercredi 27 mai 2009
Statut
Modérateur
Dernière intervention
28 mai 2023
14 182
22 août 2021 à 14:25
22 août 2021 à 14:25
Bonjour,
Regarde ceci -->> Marquer un fil de discussion comme étant résolu
Comment on fait pour clore ce sujet ?
Regarde ceci -->> Marquer un fil de discussion comme étant résolu