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?

6
  • Why? Why is it a problem? Maybe an XY problem. Commented May 26, 2022 at 7: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? Commented May 26, 2022 at 7: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. Commented May 26, 2022 at 7:20
  • @StéphaneChazelas I am using Alacritty. Commented May 26, 2022 at 7:20
  • @StéphaneChazelas it seems like a terminal emulator issue. In gnome terminal, both gives ^M. Commented May 26, 2022 at 7:24

1 Answer 1

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.

1
  • Great answer! NB with the recent toml config, I had to add this to make it work: ``` [[keyboard.bindings]] chars = "\r" key = "NumpadEnter" ``` Commented Feb 13, 2024 at 14:43

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.