按键速度按住键时 [英] Keypress speed when holding down key
问题描述
有没有加一按键事件和下一步相同的键之间的延迟的方法?
Is there a way to increase the delay between one keypress event and the next for the same key?
我有一个应用程序,用户可以通过图像使用滚动向下/向上键。他们可以按下并释放或他们可以保持在按下状态。有些时候用户希望当他们保持键向上/向下按下所有的时间更快滚动。
一路按键事件,接下来我相信是由Windows控制的,所以我们说,如果我打开中的字母a和我保持键,记事本和类型,然后我看到的速度是基于之间的间隔时间在参数Windows控件我相信。
I have an application where the user can scroll through images using the down/up key. They can press and release or they can just keep it pressed. There are times when the user would like to scroll faster when they maintain the key up/down pressed all the time. The duration between one keypress event and the next I believe is controlled by Windows, so let's say, if I open notepad and type in the letter "a" and I keep the key down, then the speed I see is based on a parameter Windows controls I believe.
我可以改变在运行时的速度在我的C#程序?一旦用户关闭应用程序,然后返回到正常速度率
Can I change that speed in runtime in my C# program? And once the user closes the app, then return to the normal speed rate.
谢谢!
推荐答案
我会用这样的:
private int counter = 0;
//...
private void OnKeyDown(...)
{
counter++;
if (counter == <value>) //it is based on the speed
{
counter = 0;
this.scrollDown();
}
}
或者你可以使用定时器
,让您向下滚动仅过了一段时间已经过去了。
只需使用一个全球性的布尔
键,将其设置为真正
当计时器滴答到假
当调用下滚
方法。
Or you could use a Timer
that let you scroll down only if a period of time has passed.
Just use a global bool
and set it to true
when the timer ticks a to false
when you call the scrollDown
method.
这篇关于按键速度按住键时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!