| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
This package is not in the latest version of its module.
Go to latest Published: Feb 28, 2026 License: MITThe Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Modules with tagged versions give importers more predictable builds.
When a project reaches major version v1 it is considered stable.
Package gbind provides tcell key event encoding, decoding and handling.
The NewConfiguration example demonstrates how to use gbind.
There are some limitations on reading keyboard input, which is explained in the tcell.EventKey documentation:
https://godoc.org/github.com/gdamore/tcell#EventKey
const ( LabelCtrl = "ctrl" LabelAlt = "alt" LabelMeta = "meta" LabelShift = "shift" )
Modifier labels
var ErrInvalidKeyEvent = errors.New("invalid key event")
ErrInvalidKeyEvent is the error returned when encoding or decoding a key event fails.
var UnifyEnterKeys = true
UnifyEnterKeys is a flag that determines whether or not KPEnter (keypad enter) key events are interpreted as Enter key events. When enabled, Ctrl+J key events are also interpreted as Enter key events.
type Configuration struct {
// contains filtered or unexported fields
}
Configuration maps keys to event handlers and processes key events.
func NewConfiguration() *Configuration
NewConfiguration returns a new input configuration.
Example ¶Example of creating and using an input configuration.
// Create a new input configuration to store the key bindings.
c := NewConfiguration()
handleSave := func(ev *tcell.EventKey) *tcell.EventKey {
// Save
return nil
}
handleOpen := func(ev *tcell.EventKey) *tcell.EventKey {
// Open
return nil
}
handleExit := func(ev *tcell.EventKey) *tcell.EventKey {
// Exit
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)
func (c *Configuration) Capture(ev *tcell.EventKey) *tcell.EventKey
Capture handles key events.
Example ¶Example of capturing key events.
// See the end of the NewConfiguration example.
| Back | FazBrowse Home | New Git URL |