Skip to content

feat: add word-delete-keybindings#63

Open
cooperkey wants to merge 1 commit into
vyrx-dev:masterfrom
cooperkey:feat/word-delete-keybindings
Open

feat: add word-delete-keybindings#63
cooperkey wants to merge 1 commit into
vyrx-dev:masterfrom
cooperkey:feat/word-delete-keybindings

Conversation

@cooperkey

Copy link
Copy Markdown

adds word-delete support while typing:
ctrl+w deletes the last word during an active test while preserving existing keybind.
if using termux, ctrl+h (ctrl + backspace in termux) also deletes the last word while typing.

Copilot AI review requested due to automatic review settings July 3, 2026 14:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds “delete previous word” behavior during an active typing test, wiring new keybindings in the TUI to game-level deletion logic (including a Termux-friendly mapping).

Changes:

  • Added (*game.Game).BackspaceWord() to delete the last word from the current input.
  • Updated typing key handling so ctrl+w deletes a word during an active test while preserving its existing pre-start behavior.
  • Updated ctrl+h to act as word-delete while typing (for Termux’ ctrl+backspace mapping) while keeping help behavior when not started.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
internal/tui/typing.go Routes ctrl+w / ctrl+h to word-delete during active typing while preserving pre-start bindings.
internal/game/game.go Implements word-level backspace logic that the TUI can call during a test.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/tui/typing.go
m.game = game.New(m.duration, m.mode, m.lang, m.difficulty)
m.save()
} else {
m.game.BackspaceWord() //added ctrl + w to delete a whole word only when typing begins

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ctrl + backspace would be a better choice

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yah, perhaps there's a way to auto-detect the architecture without forking any subprocesses? so when it detects non-aarch64, it will default to ^Backspace? I added the ^W since on most terminals, it deletes a whole word

Comment thread internal/tui/typing.go
Comment on lines +72 to +79
//this is for termux since it reads ctrl + backspace as ctrl + h
case "ctrl+h":
if m.game.Started() {
m.game.BackspaceWord()
} else {
m.showHelp = true
return m, nil
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

people use termux on mobile right?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, on mobile with aarch64 because it reads ^Backspace as ^h

Comment thread internal/game/game.go
Comment on lines +181 to +203
func (g *Game) BackspaceWord() {
if len(g.input) == 0 {
return
}

g.lastTyped = time.Now()

// Trim trailing spaces first
for len(g.input) > 0 && g.input[len(g.input)-1] == ' ' {
pos := len(g.input) - 1
g.input = g.input[:pos]
delete(g.errors, pos)
}

// Then delete until hitting a space or the beginning
for len(g.input) > 0 && g.input[len(g.input)-1] != ' ' {
pos := len(g.input) - 1
g.input = g.input[:pos]
delete(g.errors, pos)
}

g.recordRacePoint()
}
@vyrx-dev

vyrx-dev commented Jul 3, 2026

Copy link
Copy Markdown
Owner

wait... you just removed help keybind 😅

@cooperkey

Copy link
Copy Markdown
Author

wait... you just removed help keybind 😅

The ^H will only activate when there is an active test. The help keybind stays the same before starting the test hehe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants