Sunday, April 16, 2023

keyboard

 

According to Archlinux wiki and How Keys Are Turned Into Actions , here comes how keystroke information is transferred in computer.
  • Keyboard send scancode to computer
  • Linux kernel convert scancode to keycode
  • Keyboard layout convert keycode to symbol/keysym
  • Linux terminal convert keysym into ASCII sequences
And there are two types of key (see link )
  • Ordinary key, like "a", "b". we should use them to input text
  • Special keys, which you would use to tell xterm to perform some action. They could not be to used to input text. They will generate escape sequences.
.inputrc is readline initialization file and used to map key sequence to readline function like "end-of-history". Then you need to use text to describe "special keys" or "escape sequences", see following example.
  • "\e[1~": beginning-of-line      # Home Key
  • "\e[4~": end-of-line            # End Key
  • "\e[3~": delete-char      # Delete Key
  • "\e\e[C": forward-word      # Alt-Right
You could use "showkey -k" or "od -c" to show escape sequence of special keys.

No comments: