kovidgoyal / kitty

Cross-platform, fast, feature-rich, GPU based terminal
https://sw.kovidgoyal.net/kitty/
GNU General Public License v3.0
24.25k stars 976 forks source link

Pressing Print_Screen writes 7361u to the terminal #4328

Closed jamessan closed 2 years ago

jamessan commented 2 years ago

Describe the bug Press Print Screen key and part (7361u) of the escape code (CSI 57361u) is written to the terminal. How much seems to depend on the shell (zsh - 7361u, bash - 361u, dash - the entire thing), however I wouldn't expect anything by default.

Output from kitty --debug-input:

Press xkb_keycode: 0x6b clean_sym: Print composed_sym: Print mods: none glfw_key: 57361 (PRINT_SCREEN) xkb_key: 65377 (Print)
on_key_input: glfw key: 0xe011 native_code: 0xff61 action: PRESS mods: none text: '' state: 0 sent encoded key to child
Release xkb_keycode: 0x6b clean_sym: Print mods: none glfw_key: 57361 (PRINT_SCREEN) xkb_key: 65377 (Print)
on_key_input: glfw key: 0xe011 native_code: 0xff61 action: RELEASE mods: none text: '' state: 0 ignoring as keyboard mode does not support encoding this event

Environment details

kitty 0.23.1 (3d59e4eac1) created by Kovid Goyal
Linux odin 5.15.0-2-amd64 #1 SMP Debian 5.15.5-1 (2021-11-26) x86_64
Debian GNU/Linux bookworm/sid odin pts3

Running under:X11
Frozen: False
Paths:
  kitty: /home/jamessan/src/github.com/kitty/kitty/launcher/kitty
  base dir: /home/jamessan/src/github.com/kitty
  extensions dir: /home/jamessan/src/github.com/kitty/kitty
  system shell: /bin/zsh
Loaded config files:
  /etc/xdg/kitty/kitty.conf
  /home/jamessan/.config/kitty/kitty.conf

Config options different from defaults:
enable_audio_bell     False
font_size             9.0
update_check_interval 0.0
Removed mouse actions:
     b1 -2 ungrabbed mouse_handle_click selection link prompt
Colors:
    background            #151515   
    color0                #151515   
    color15               #e8e8d3   
    foreground            #e8e8d3   

Additional context Try to reproduce the problem with kitty --config NONE if you cannot then post a minimal kitty.conf that reproduces the problem. If the problem involves interaction with some other terminal program post a minimal config for that program to reproduce the problem as well.

kovidgoyal commented 2 years ago

This is by design. Keys not representable in the traditional terminal encoding are now sent using the new kitty keyboard protocol, even in legacy mode. See discussion in https://github.com/kovidgoyal/kitty/issues/3248

yangyingchao commented 2 years ago

I know this is an old thread, but I wonder if it is possible to disable this behaviour: it is somewhat annoying to see these charactors in the terminal after "PrintScreen" is pressed..

Thanks.

kovidgoyal commented 2 years ago

Map it to discard_event in kitty.conf

yangyingchao commented 2 years ago

Map it to discard_event in kitty.conf

Thanks!

jvasile commented 2 years ago

Just in case anybody is looking in this thread for a solution, add this to your kitty.conf:

 map print_screen discard_event
marckleinebudde commented 2 years ago

Doesn't work for me:

$ grep print ~/.config/kitty/kitty.conf
map print_screen discard_event
$ kitty --version
kitty 0.21.2 created by Kovid Goyal
$ kitty --debug-keyboard
[151 10:39:07.514080] Ignoring unknown config key: open_url_modifiers
[151 10:39:07.514189] Ignoring unknown config key: rectangle_select_modifiers
[151 10:39:07.514219] Ignoring unknown config key: terminal_select_modifiers
Loading new XKB keymaps
Modifier indices alt: 0x3 super: 0x6 hyper: 0xffffffff meta: 0xffffffff numlock: 0x4 shift: 0x0 capslock: 0x1
Move mouse_button: -1 mods: none grabbed: 0
Press xkb_keycode: 0x6b clean_sym: Print composed_sym: Print mods: none glfw_key: 57361 (PRINT_SCREEN) xkb_key: 65377 (Print)
on_key_input: glfw key: 0xe011 native_code: 0xff61 action: PRESS mods: none text: '' state: 0 sent key to child
Release xkb_keycode: 0x6b clean_sym: Print mods: none glfw_key: 57361 (PRINT_SCREEN) xkb_key: 65377 (Print)
on_key_input: glfw key: 0xe011 native_code: 0xff61 action: RELEASE mods: none text: '' state: 0 ignoring as keyboard mode does not support encoding this event
Press xkb_keycode: 0x6b clean_sym: Print composed_sym: Print mods: none glfw_key: 57361 (PRINT_SCREEN) xkb_key: 65377 (Print)
on_key_input: glfw key: 0xe011 native_code: 0xff61 action: PRESS mods: none text: '' state: 0 sent key to child
Release xkb_keycode: 0x6b clean_sym: Print mods: none glfw_key: 57361 (PRINT_SCREEN) xkb_key: 65377 (Print)
on_key_input: glfw key: 0xe011 native_code: 0xff61 action: RELEASE mods: none text: '' state: 0 ignoring as keyboard mode does not support encoding this event
Press xkb_keycode: 0x85 clean_sym: Super_L composed_sym: Super_L mods: none glfw_key: 57444 (LEFT_SUPER) xkb_key: 65515 (Super_L)
on_key_input: glfw key: 0xe064 native_code: 0xffeb action: PRESS mods: none text: '' state: 0 ignoring as keyboard mode does not support encoding this event
on_key_input: glfw key: 0xe064 native_code: 0xffeb action: RELEASE mods: none text: '' state: 0 ignoring as keyboard mode does not support encoding this event

For each press of Print Screen it prints 361u to the new terminal window.

kovidgoyal commented 2 years ago

your version of kitty is too old

marckleinebudde commented 2 years ago

With the latest nightly ("Nightly release, generated on: 2022-05-29 21:26:02 UTC from commit: 581c388."), same result :cry:

$ grep print ~/.config/kitty/kitty.conf                                                                      
map print_screen discard_event

$ ./local/kitty/bin/kitty --version                               
kitty 0.25.1 created by Kovid Goyal

$ ./local/kitty/bin/kitty --debug-keyboard                        
[151 15:10:48.583923] Ignoring unknown config key: open_url_modifiers
[151 15:10:48.584279] Ignoring unknown config key: rectangle_select_modifiers
[151 15:10:48.584361] Ignoring unknown config key: terminal_select_modifiers
Loading new XKB keymaps
Modifier indices alt: 0x3 super: 0x6 hyper: 0xffffffff meta: 0xffffffff numlock: 0x4 shift: 0x0 capslock: 0x1
Move x: 751.0 y: 296.0 grabbed: 0
Press xkb_keycode: 0x6b clean_sym: Print composed_sym: Print mods: none glfw_key: 57361 (PRINT_SCREEN) xkb_key: 65377 (Print)
on_key_input: glfw key: 0xe011 native_code: 0xff61 action: PRESS mods: none text: '' state: 0 sent encoded key to child
Release xkb_keycode: 0x6b clean_sym: Print mods: none glfw_key: 57361 (PRINT_SCREEN) xkb_key: 65377 (Print)
on_key_input: glfw key: 0xe011 native_code: 0xff61 action: RELEASE mods: none text: '' state: 0 ignoring as keyboard mode does not support encoding this event
Press xkb_keycode: 0x6b clean_sym: Print composed_sym: Print mods: none glfw_key: 57361 (PRINT_SCREEN) xkb_key: 65377 (Print)
on_key_input: glfw key: 0xe011 native_code: 0xff61 action: PRESS mods: none text: '' state: 0 sent encoded key to child
Release xkb_keycode: 0x6b clean_sym: Print mods: none glfw_key: 57361 (PRINT_SCREEN) xkb_key: 65377 (Print)
on_key_input: glfw key: 0xe011 native_code: 0xff61 action: RELEASE mods: none text: '' state: 0 ignoring as keyboard mode does not support encoding this event
Press xkb_keycode: 0x25 clean_sym: Control_L composed_sym: Control_L mods: none glfw_key: 57442 (LEFT_CONTROL) xkb_key: 65507 (Control_L)
on_key_input: glfw key: 0xe062 native_code: 0xffe3 action: PRESS mods: none text: '' state: 0 ignoring as keyboard mode does not support encoding this event
Press xkb_keycode: 0x36 clean_sym: c composed_sym: c mods: ctrl glfw_key: 99 (c) xkb_key: 99 (c)
on_key_input: glfw key: 0x63 native_code: 0x63 action: PRESS mods: ctrl text: '' state: 0 sent encoded key to child
Release xkb_keycode: 0x36 clean_sym: c mods: ctrl glfw_key: 99 (c) xkb_key: 99 (c)
on_key_input: glfw key: 0x63 native_code: 0x63 action: RELEASE mods: ctrl text: '' state: 0 ignoring as keyboard mode does not support encoding this event
Press xkb_keycode: 0x28 clean_sym: d composed_sym: d mods: ctrl glfw_key: 100 (d) xkb_key: 100 (d)
on_key_input: glfw key: 0x64 native_code: 0x64 action: PRESS mods: ctrl text: '' state: 0 sent encoded key to child
kovidgoyal commented 2 years ago

Then you arent actually mapping what you think you are mapping.

kitty --config=NONE -o 'map print_screen discard_event'

will work.

marckleinebudde commented 2 years ago

This works. It seems to be relevant where in the config file that line is placed. Works now. Thanks for your patience, sorry for the noise!

marckleinebudde commented 2 years ago

your version of kitty is too old

For the record, now it works even with: kitty 0.21.2 created by Kovid Goyal

marckleinebudde commented 2 years ago

For the record, there are some more events you might want to discard:

map print_screen discard_event
map ctrl+print_screen discard_event
map alt+print_screen discard_event
map super+print_screen discard_event