[C#]如何阅读已持有的密钥。 [英] [C#] How to read a key which has held.

查看:107
本文介绍了[C#]如何阅读已持有的密钥。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我有一个问题。有了这些代码,一切都没问题,但是当我按下一个键时。

就像A + A + A +一样,它一直按下键多次。

如何获得A +而不是A + A + A +?





Hello , I've got a question. With those codes everything is alright but when I hold down a key.
It goes like "A+A+A+" It keeps pressing the key multiple times.
How do I get "A+" instead of "A+A+A+"?


private void gridView1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode >= Keys.A && e.KeyCode <= Keys.Z)
            {
              
                gridView1.GetFocusedDataRow()["Shortcut"] =gridView1.GetFocusedDataRow()["Shortcut"]+ e.KeyCode.ToString()+"+";
            }

        }

推荐答案

这是预期的行为:它叫Autorepeat并且这正是假设发生的事情,因此您的用户可以按住一个键并获取它的多个实例:例如按住连字符按钮并获得一行破折号。



如果你想停止它,你还需要处理KeyUp事件并自己动手。可能有点乱,特别是如果他们用鼠标移动到其他地方并回来......
That is the expected behaviour: it's call "Autorepeat" and it is exactly what is suppose to happen, so your user can hold down a key and get multiple instances of it: like holding down the "hyphen" button and getting a row of dashes.

If you want to stop it, you will need to handle the KeyUp event as well and do it yourself. Might be a little messy, particularly if they use the mouse to move elsewhere and come back...


这篇关于[C#]如何阅读已持有的密钥。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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