radlinskii / donkeytype

typing test TUI app
MIT License
17 stars 15 forks source link

handle shortcuts for deleting last word from the input #6

Closed radlinskii closed 1 year ago

radlinskii commented 1 year ago

On MacOS it makes a lot of sense to have <Alt>+<Backspace> deleting characters from current cursor position till beginning of the word (till white space character). It might be easier to type a word again if there were any mistakes in it.

aashirbadb commented 1 year ago

Hi, can I work on this?

radlinskii commented 1 year ago

Sure 👍

aashirbadb commented 1 year ago

I was able to get alt+backspace working but on windows and linux the shortcut to delete last word is ctrl+backspace. It looks like crossterm gives ctrl+h(konsole, alacritty) or ctrl+w(VSCode terminal) when ctrl+backspace is pressed. We can probably detect those keys and delete the last word.

Using PushKeyboardEnhancementFlags seems to give the correct event but it only works on terminals which support the kitty keyboard protocol

We can probably use PushKeyboardEnhancementFlags for terminals that support it(using crossterm::terminal::supports_keyboard_enhancement and use ctrl+h and ctrl+w if it is not supported. Does that sound good?

radlinskii commented 1 year ago

Perfect 👌