[英]Removing Key Press Delay
I'm writing a game in C using the Gtk libraries, in which the player controls a movable character. 我正在使用Gtk库用C编写游戏,其中玩家控制了可移动角色。 However, I want the player to be able to hold a key to continuously move in one direction.
但是,我希望玩家能够按住一个键来连续向一个方向移动。 How do I override the normal behavior for holding a key, in which a key event is generated, there is a brief pause, and then key events occur in a continuous stream?
如何覆盖按住键的正常行为,即生成键事件,短暂停顿然后在连续流中发生键事件?
I've noticed a similar question was asked previously about doing the same thing in Javascript; 我注意到之前有人问过一个类似的问题,关于在Javascript中执行相同的操作; however, the answer doesn't really assist with implementing the same system in Gtk.
但是,答案并没有真正帮助在Gtk中实现相同的系统。 I've noticed that there is a GtkDevice "class";
我注意到有一个GtkDevice“ class”; is there a function having to do with it that will allow me to control the buffering of keyboard input?
是否有与之相关的功能可以让我控制键盘输入的缓冲?
Connect to GTK's key_press_event
and key_release_event
signals. 连接到GTK的
key_press_event
和key_release_event
信号。
They will work as you describe. 它们将按照您的描述工作。
It will be your responsibility to track whether the keys you are interested in are currently pressed at a given time. 您有责任跟踪在给定时间当前是否按下了您感兴趣的键。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.