Watch
1
0
Fork
You've already forked golang-codeberg-tslocum-cbind
0
No description
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Daniel Baumann b9911e45b0
Releasing fastforward version 0.1.9-2~ffwd13+u1.
Signed-off-by: Daniel Baumann <daniel@debian.org>
2026-08-04 03:32:58 +02:00
debian Releasing fastforward version 0.1.9-2~ffwd13+u1. 2026-08-04 03:32:58 +02:00
whichkeybind Adding upstream version 0.1.9. 2026-07-08 17:00:35 +02:00
.gitignore Adding upstream version 0.1.9. 2026-07-08 17:00:35 +02:00
CHANGELOG Adding upstream version 0.1.9. 2026-07-08 17:00:35 +02:00
configuration.go Adding upstream version 0.1.9. 2026-07-08 17:00:35 +02:00
configuration_test.go Adding upstream version 0.1.9. 2026-07-08 17:00:35 +02:00
doc.go Adding upstream version 0.1.9. 2026-07-08 17:00:35 +02:00
go.mod Adding upstream version 0.1.9. 2026-07-08 17:00:35 +02:00
go.sum Adding upstream version 0.1.9. 2026-07-08 17:00:35 +02:00
key.go Adding upstream version 0.1.9. 2026-07-08 17:00:35 +02:00
key_test.go Adding upstream version 0.1.9. 2026-07-08 17:00:35 +02:00
LICENSE Adding upstream version 0.1.9. 2026-07-08 17:00:35 +02:00
README.md Adding upstream version 0.1.9. 2026-07-08 17:00:35 +02:00

cbind

GoDoc Donate

Key event handling library for tcell

Features

  • Set KeyEvent handlers
  • Encode and decode KeyEvents as human-readable strings

Usage

// Create a new input configuration to store the key bindings.
c := NewConfiguration()

// Define save event handler.
handleSave := func(ev *tcell.EventKey) *tcell.EventKey {
    return nil
}

// Define open event handler.
handleOpen := func(ev *tcell.EventKey) *tcell.EventKey {
    return nil
}

// Define exit event handler.
handleExit := func(ev *tcell.EventKey) *tcell.EventKey {
    return nil
}

// Bind Alt+s.
if err := c.Set("Alt+s", handleSave); err != nil {
    log.Fatalf("failed to set keybind: %s", err)
}

// Bind Alt+o.
c.SetRune(tcell.ModAlt, 'o', handleOpen)

// Bind Escape.
c.SetKey(tcell.ModNone, tcell.KeyEscape, handleExit)

// Capture input. This will differ based on the framework in use (if any).
// When using tview or cview, call Application.SetInputCapture before calling
// Application.Run.
app.SetInputCapture(c.Capture)

Documentation

Documentation is available via gdooc.

The utility program whichkeybind is available to determine and validate key combinations.

go install codeberg.org/tslocum/cbind/whichkeybind@latest

Support

Please share issues and suggestions here.