按键事件-降温 [英] Keydown event - cool down

查看:67
本文介绍了按键事件-降温的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有按键事件的项目,但是每次按键时,我都单击该按键,如果我按住它,它将等待半秒钟并快速启动垃圾邮件按键.我需要它在不冷静的情况下发送垃圾邮件,我该怎么办?

I have a project with keydown event, but as every keypress, i click on the key and if i kip clicking it, it will wait a half second and start spam quickly the key. I need it to spam with no cool down, what can i do?

推荐答案

您无需更改系统范围的设置,但仍会有250ms的延迟,您可以观看同一键的keydown和keyup事件(请不要忘记用户可以一次按下多个键,然后以不同的顺序释放它们).在按下按键时以所需的频率启动一个计时器,在按下按键时将其停止,然后将之前的按下按键处理程序设置为计时器处理程序.

Instead of changing the system-wide settings and still have a delay of 250ms, you can watch keydown and keyup events for the same key (don't forget that a user can press multiple keys at once and release them in different order). Start a timer with required frequency on keydown, and stop it on the keyup, and set your previous keydown handler as a timer handler.

这篇关于按键事件-降温的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆