接受Ctrl + A,Alt + 1等键击等 [英] Accept key strokes like Ctrl+A, Alt+1 etc etc

查看:117
本文介绍了接受Ctrl + A,Alt + 1等键击等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何接受像Ctrl + A等等的击键...我的意思是两把钥匙的组合......请给出一小段代码来展示......


i在linux平台下使用gcc

How can i accept key strokes like Ctrl+A etc etc ... i mean combination of 2 keys... Pls give a small peice of code to demonstrate...

i use gcc under linux platform

推荐答案

有几种方法可以获得击键。如果您可以提供更多项目背景,将会有所帮助。具体来说,您是在编写gui或命令行驱动的应用程序吗?另外,如果您正在制作gui,您使用的是什么库?
There are several ways to get key strokes. It will help if you can give more background on your project. Specifically, are you writing a gui or command line driven application? Also, if you''re making a gui, what library are you using?


您感兴趣的所有2键组合是否都涉及Control键?请注意,Shift键涉及用户的双键操作,但只会导致一个字符进入您的程序。 Control键类似。 ASCII表将显示与Control键组合相关的键码。


另一方面,某些键(通常是箭头键)是用户的单键操作,但程序的关键序列。

@shadyabhi
Do all of the 2-key combinations you''re interested in involve the Control key? Notice that the Shift key involves two-key operation by the user but results in only a single character going to your program. The Control key is similar. An ASCII table will show you the key codes associated with Control key combinations.

On the other hand, there are certain keys (typically arrow keys) that are single-key operations by the user, but key sequences to the program.

@shadyabhi


我不得不写在某些时候点击按键程序,我这样做的方式是观察键被按下和释放的时间...所以如果你收到一条消息(实际上在我的情况下是大量的消息)说正在按下按键,然后在大写之后发生任何事情,直到Shift键被释放。任何多键组合都是一样的。据我所知,你不可能同时看到多个按键,所以你必须有一些方法,一些逻辑来解决它,但它并不太难。
I had to write a keystroke program at some point, and the way I did it was to watch when keys were pressed and released ... so if you''re getting a message ( actually in my case a ton of messages ) saying shift is being held down, then whatever comes after that is capitalized, up until the shift key is released. It''s the same for any multiple key combination. As far as I know, you can''t really see multiple key presses simultaneously, so you have to have some method, some logic to figure it out, but it''s not too difficult.


这篇关于接受Ctrl + A,Alt + 1等键击等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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