简体   繁体   English

如何在Elisp中收听Keypresses?

[英]How to listen to Keypresses in Elisp?

I want to make a function that counts keyboard presses. 我想创建一个计算键盘按下的功能。 Is there any function or hook that would let me listen to the input without modifying it? 是否有任何函数或钩子可以让我在不修改输入的情况下听取输入?

I've tried read-event and read-char, set some variable that read input, incremented the number of keyboard presses and then inserted it into the file, but it failed. 我尝试过read-event和read-char,设置了一些读取输入的变量,增加了键盘按下次数,然后将其插入到文件中,但是失败了。 It prevents you from using any keystrokes, it also interprets keys like Backspace as a "/?", thus making it impossible to delete text. 它会阻止您使用任何击键,它还会将Backspace之类的键解释为“/?”,从而无法删除文本。

找到它,你只需要使用(add-hook post-self-insert-hook #'function) ,它在每次按键后执行function

你可能想看一下post-command-hook

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM