简体   繁体   English

如何在带有termios的Linux中将Delete键分配给另一个字符?

[英]How do I assign the delete key to another character in Linux with termios?

I've working on this problem where I need to assign a character to a become the delete key in Linux with termios. 我正在解决这个问题,我需要分配一个字符以使其成为带有termios的Linux中的删除键。 I've looked up resources and it seems like everyone is doing it this way but for some reason I cannot get it to work. 我查找了资源,似乎每个人都在这样做,但是由于某种原因,我无法使它正常工作。

So I am trying to bind the 'q' character to become the new delete key. 因此,我试图将'q'字符绑定为新的删除键。 This is what I have. 这就是我所拥有的。 I am assigning the 'q' character be the new backspace but when I compile and run 'q' doesn't delete anything. 我将'q'字符分配为新的退格键,但是当我编译并运行'q'时不会删除任何内容。

#include <stdio.h>
#include <termios.h>
int main()
{
struct termios err;
err.c_cc[VERASE] = 'q';
return 0;
}

cough 咳嗽

 ...
  struct termios err;
  tcgetattr(0, &err);
  err.c_cc[VERASE] = 'q';
  tcsetattr(0, TCSANOW, &err);
 ...

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

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