双键代码!!! [英] double key code !!!
本文介绍了双键代码!!!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨!
如何在键盘上为2个键编写一些代码?例如:当用户点击
时,我想显示标签
这两个键都是Alt和F,那我该怎么办? ;最好告诉我知道如何为一个键编写一些代码,例如Enter
(我应该去keyDown并...),以便您可以更轻松地告诉我; D
Hi!
How to write some codes for 2 keys on the keyboard ? eg: i wanna show a label when user clicked on the
both keys, Alt and F so what should i do? ; its better to tell i know how to write some codes for one key for example Enter
( i should go to keyDown and ...) so u can tell me easier ;D
推荐答案
使用KeyDown和KeyUp代替KeyPress或P/Invoke GetKeyboardState.
您应该启用 KeyPreview [链接 [
Use KeyDown and KeyUp instead of KeyPress, or P/Invoke GetKeyboardState.
You should enable the KeyPreview[^] property. This link[^] will explain you the basics.
A tiny sample code will be like:
private void ctrl_KeyDown(object sender, KeyEventArgs e)
{
if (e.Control && e.KeyCode == Keys.C)
{
// Do stuff when Ctrl+C pressed
}
}
有关更多信息:
C#密钥处理技术 [
For further information:
C# Key processing techniques[^]
Good luck,
OI
这篇关于双键代码!!!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文