检测键盘输入 [英] Detect keyboard input

查看:110
本文介绍了检测键盘输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我刚刚开始实施与usb键盘集成的winform。我尝试在互联网上搜索,但我没有找到任何成功的键盘输入。



如果你们有建议,我需要指导完整的构建应用程序与USB集成键盘,从导入,声明和keydown值开始。我希望有人能为我提供指南的链接。也许我在搜索引擎中搜索措辞时错了。 TQ



从下面的评论中复制的其他信息

我为此处提出一个混淆问题而道歉。实际上我使用WinForm for VB.net 2010创建了一个简单的程序,当我按下键盘上的某个键时,它会执行刷新列表视图(F5),取消输入(Esc),保存(Ctrl + S)等操作。 。我这个集成意味着我需要指定按哪个键来执行前面所述的特定操作。我假设我将使用键盘执行所有这些功能而不是鼠标点击。我不想使用Alt + XXXX,我可以把它放在按钮功能上,字符上有_(如果你有我的意思)

解决方案

假设键盘是一个标准设备,它根本不需要你的工作,除非你想捕获一些击键组合并在你的应用程序中将它们用作热键。

键盘被处理通过操作系统,只需通过正常事件传递数据,无论是PS /还是USB,无论您是否插入一个,两个或七个物理键盘。我经常连接两个键盘时间(对于不同的布局/语言),它完全按照您的预期 - 无缝地工作。


所以你想要简单的快捷方式。

首先,如果您使用按钮快捷方式可用性是默认的。只需在文本中添加一个放大器: Button1.Text =& Ok; ,并且您有Alt + O作为快捷方式(但是你没有出于某种原因想要这个)。有了菜单,你有更多的可能性,请看这里: http://msdn.microsoft.com/en-us/library/system.windows.forms.menuitem.shortcut(v = vs.110).aspx [ ^ ] 。如果您希望有更通用的方法来为自定义操作添加自定义快捷方式,可以在此处查看: http:// snipplr .com / view / 57156 / [ ^ ]。

Hi all,

I'm just start implementing winform which integrate with usb keyboard. I try to search on the internet but I don't found any success keyboard input.

If you guys have suggestion, I need guide for complete build app integrate with USB keyboard which start from import,declaring and keydown value. I wish someone could provide me a link to the guideline. Maybe I'm wrong in searching a wording in search engine. TQ

additional information copied from comment below
I apologize for making a confuse question here. Actually I create a simple program using WinForm for VB.net 2010 which when I press a certain key on keyboard, it will perform action such as refresh listview(F5),cancel input (Esc),saving (Ctrl+S) and so on. I guest this integrate mean I need to specify which key is press to perform specific action as stated before. I assume that I will perform all those function using keyboard not by mouse to click. I dont want to use the Alt + XXXX where I can put it on the button function with the _ on the character (if you got what I mean)

解决方案

Assuming that the keyboard is a standard device, then it needs no work on your part at all, unless you want to capture some keystroke combinations and use them as "hotkeys" in your application.
A keyboard is handled by the OS and just passes data through via the normal events, regardless of whether it is PS/" or USB, and regardless of whether you have one, two or seven physical keyboards plugged in. I have often had two keyboards connected at the same time (for different layout/languages) and it all works exactly as you would expect - seamlessly.


So you want simple shortcuts.
First of all, if you use buttons shortcut availability is default. Simply put an amp in the text: Button1.Text = "&Ok"; , and you have Alt+O as shortcut (but you don't want this for some reason). With menus, you have even more possibilities, see here: http://msdn.microsoft.com/en-us/library/system.windows.forms.menuitem.shortcut(v=vs.110).aspx[^]. If you want to have more general approach to be able to add custom shortcuts to custom actions, you can have a look here: http://snipplr.com/view/57156/[^].


这篇关于检测键盘输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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