赞
踩
-
- private void Form1_Load(object sender, EventArgs e)
- {
-
- this.KeyPreview = true;
-
- }
- protected override bool ProcessDialogKey(Keys keyData)
- {
- if (keyData == Keys.Left || keyData == Keys.Right || keyData == Keys.Up || keyData == Keys.Down)
- {
- switch (keyData)
- {
- case Keys.Left:
- KeyLeftPress();
- break;
- case Keys.Right:
- KeyRightPress();
- break;
- case Keys.Up:
- KeyUpPress();
- break;
- case Keys.Down:
- KeyDownPress();
- break;
- }
- }
- return base.ProcessDialogKey(keyData);
- }
- public void KeyLeftPress()
- {
-
- }
- public void KeyRightPress()
- {
-
- }
- private void KeyUpPress()
- {
-
- }
- private void KeyDownPress()
- {
-
- }
-
- private void Form1_KeyPress(object sender, KeyPressEventArgs e)
- {
- this.Text = e.KeyChar.ToString();
-
- }

为什么不能触发Form1_keydown事件?-CSDN社区
https://bbs.csdn.net/topics/391894242
C# KeyDown事件-CSDN博客
https://blog.csdn.net/fangyu723/article/details/108827544
- private void Form1_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Left)
- this.Left -= 100;
- if (e.KeyCode == Keys.Right)
- this.Left += 100;
- if (e.KeyCode == Keys.Up)
- this.Left -= 10;
- if (e.KeyCode == Keys.Down)
- this.Left += 10;
-
- }
Form窗体中判断按键信息_form1_keyup-CSDN博客
https://blog.csdn.net/wuhongyao3/article/details/3959667
特此记录
anlog
2024年1月29日
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。