3

I am using the alacritty terminal emulator under Zorin 16. My two enter keys are giving different output.

% showkey -a

Press any keys - Ctrl-D will terminate this program

^M   13 0015 0x0d
^J   10 0012 0x0a

Primary Enter Key is giving ^M, The Numpad Enter Key is giving ^J.

This is true for both bash and zsh.

I want both keys to give ^M.

How can I achieve this?

Stéphane Chazelas
  • 522,931
  • 91
  • 1,010
  • 1,501
Ahmad Ismail
  • 2,478
  • 1
  • 22
  • 47
  • Why? Why is it a problem? Maybe an [XY problem](https://meta.stackexchange.com/a/66378/355310). – Kamil Maciorowski May 26 '22 at 07:07
  • What terminal or terminal emulator are you using? Do you see a difference after running `tput smkx` or `tput rmkx` or with or without NumLock enabled? – Stéphane Chazelas May 26 '22 at 07:20
  • @KamilMaciorowski i use both enter key interchangeably. But in my machine, I can not use the numlock enter key to do what it is supposed to do. When I press the second enter key, it does nothing. – Ahmad Ismail May 26 '22 at 07:20
  • @StéphaneChazelas I am using Alacritty. – Ahmad Ismail May 26 '22 at 07:20
  • @StéphaneChazelas it seems like a terminal emulator issue. In gnome terminal, both gives `^M`. – Ahmad Ismail May 26 '22 at 07:24
  • Are you sure you have two Enter keys? Most typical keyboards have a Carriage Return key on the "typewriter" part of the keyboard and only have a single Enter key on the numerical keypad. – Jörg W Mittag May 26 '22 at 09:23

1 Answers1

3

Yes, it seems alacritty is configured by default to send LF (aka \n, ^J) upon keypad enter, and also regardless of whether application keypad mode is enabled (after tput smkx) even though the terminfo entry (on Ubuntu 20.04 at least) has kent=\EOM, while all other terminals send CR (and most send \EOM after tput smkx).

You can change it by adding:

key_bindings:
  - { key: NumpadEnter, chars: "\r" }

To your ~/.config/alacritty.yml (or your preferred path for that file, there are several options, see manual).

Note that in any case, the terminal device driver is generally configured by default to translate CR to LF automatically upon input (look for icrnl in the output of stty -a), so it would generally not make much difference in practice. It's only for those TUI applications that disable that setting (as showkey does) that you may see a difference.

Stéphane Chazelas
  • 522,931
  • 91
  • 1,010
  • 1,501