jrnxf / thokr

✨ sleek typing tui with visualized results and historical logging
MIT License
518 stars 18 forks source link

ctrl+backspace to delete last word #9

Closed RomanHauksson closed 2 years ago

RomanHauksson commented 2 years ago

Problem

When I press Ctrl+Backspace, I'd expect the last word to be deleted – this is the behavior of most text input boxes, and Monkeytype. Instead, it adds a new character.

Solution

I don't know exactly how to implement this feature. It could be an optional argument in the CLI.

Additional context

Video demonstrating the behavior. I mistype the word "possible" and attempt to delete the whole word.

https://user-images.githubusercontent.com/62364808/166745675-61dd4d1f-3972-4353-b151-3eec35ea3da9.mp4

jrnxf commented 2 years ago

Unfortunately this is a limitation of the terminal backend crossterm which handles user input. Essentially the control modifier never registers when a user hits backspace. You can read more about the issue here.

I'm keeping a close eye on this issue myself because I also want to see this added! I'm glad you said what you did though, because in my head ctrl+backspace should delete the whole line back to the beginning, but I think going back to the start of the current word makes more sense for what this is. You mentioned that most typing tests do that, but out of curiosity if you press ctrl+backspace in a normal text field or document, does it delete the entire line as it does for me? That's always what I've associated ctrl+backspace as doing.

RomanHauksson commented 2 years ago

Ah, that's tough! I guess we'll just have to wait on that crossterm issue. Ctrl+backspace does just delete the last word for me, I assumed that's how it works for most people – never heard of it deleting a line. TIL

jrnxf commented 2 years ago

Closing this just because I have my eyes on the issue and know it's main blocker!