getch

package module
v0.0.0-...-95cb209 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2025 License: MIT Imports: 5 Imported by: 0

README

Go Getch (Windows)

A simple Go library for reading single characters (including special keys like arrows) from the Windows console without echoing, similar to the C getch() function. Uses standard library packages (golang.org/x/sys/windows) only.

Installation

go get github.com/a123ao/go-getch

Usage

package main

import (
    "fmt"
    "github.com/a123ao/go-getch"
)

func main() {
    fmt.Println("Press `Enter` to quit")
    for {
        key, _ := getch.Read()
        if key.VirtualKeyCode == getch.VK_ENTER {
            break
        }
        fmt.Println("Key pressed:", key.UnicodeChar, key.VirtualKeyCode)
    }
}

Documentation

Index

Constants

View Source
const (
	// VIRTUAL KEYS
	VK_UP    = uint16(0x26) // Up arrow key
	VK_DOWN  = uint16(0x28) // Down arrow key
	VK_LEFT  = uint16(0x25) // Left arrow key
	VK_RIGHT = uint16(0x27) // Right arrow key
	VK_ENTER = uint16(0x0D) // Enter key
	VK_SHIFT = uint16(0x10) // Shift key
)

Variables

This section is empty.

Functions

func Read

func Read() (keyboard.KEY_ENTRY, error)

Types

This section is empty.

Directories

Path Synopsis
cmd
example command
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL