...

Package kibodo

Overview ▾

Package kibodo provides an on-screen keyboard widget for Ebitengine.

Variables

KeysQWERTY is a standard QWERTY keyboard layout.

var KeysQWERTY = [][]*Key{
    {
        {
            LowerLabel: "`",
            UpperLabel: "~",
            LowerInput: &Input{Rune: '`'},
            UpperInput: &Input{Rune: '~'},
        },
        {
            LowerLabel: "1",
            UpperLabel: "!",
            LowerInput: &Input{Rune: '1'},
            UpperInput: &Input{Rune: '!'},
        },
        {
            LowerLabel: "2",
            UpperLabel: "@",
            LowerInput: &Input{Rune: '2'},
            UpperInput: &Input{Rune: '@'},
        },
        {
            LowerLabel: "3",
            UpperLabel: "#",
            LowerInput: &Input{Rune: '3'},
            UpperInput: &Input{Rune: '#'},
        },
        {
            LowerLabel: "4",
            UpperLabel: "$",
            LowerInput: &Input{Rune: '4'},
            UpperInput: &Input{Rune: '$'},
        },
        {
            LowerLabel: "5",
            UpperLabel: "%",
            LowerInput: &Input{Rune: '5'},
            UpperInput: &Input{Rune: '%'},
        },
        {
            LowerLabel: "6",
            UpperLabel: "^",
            LowerInput: &Input{Rune: '6'},
            UpperInput: &Input{Rune: '^'},
        },
        {
            LowerLabel: "7",
            UpperLabel: "&",
            LowerInput: &Input{Rune: '7'},
            UpperInput: &Input{Rune: '&'},
        },
        {
            LowerLabel: "8",
            UpperLabel: "*",
            LowerInput: &Input{Rune: '8'},
            UpperInput: &Input{Rune: '*'},
        },
        {
            LowerLabel: "9",
            UpperLabel: "(",
            LowerInput: &Input{Rune: '9'},
            UpperInput: &Input{Rune: '('},
        },
        {
            LowerLabel: "0",
            UpperLabel: ")",
            LowerInput: &Input{Rune: '0'},
            UpperInput: &Input{Rune: ')'},
        },
        {
            LowerLabel: "-",
            UpperLabel: "_",
            LowerInput: &Input{Rune: '-'},
            UpperInput: &Input{Rune: '_'},
        },
        {
            LowerLabel: "=",
            UpperLabel: "+",
            LowerInput: &Input{Rune: '='},
            UpperInput: &Input{Rune: '+'},
        },
        {
            LowerLabel: "Backspace",
            UpperLabel: "BACKSPACE",
            LowerInput: &Input{Key: ebiten.KeyBackspace},
            UpperInput: &Input{Key: ebiten.KeyBackspace},
        },
    },
    {
        {
            LowerLabel: "q",
            UpperLabel: "Q",
            LowerInput: &Input{Rune: 'q'},
            UpperInput: &Input{Rune: 'Q'},
        },
        {
            LowerLabel: "w",
            UpperLabel: "W",
            LowerInput: &Input{Rune: 'w'},
            UpperInput: &Input{Rune: 'W'},
        },
        {
            LowerLabel: "e",
            UpperLabel: "E",
            LowerInput: &Input{Rune: 'e'},
            UpperInput: &Input{Rune: 'E'},
        },
        {
            LowerLabel: "r",
            UpperLabel: "R",
            LowerInput: &Input{Rune: 'r'},
            UpperInput: &Input{Rune: 'R'},
        },
        {
            LowerLabel: "t",
            UpperLabel: "T",
            LowerInput: &Input{Rune: 't'},
            UpperInput: &Input{Rune: 'T'},
        },
        {
            LowerLabel: "y",
            UpperLabel: "Y",
            LowerInput: &Input{Rune: 'y'},
            UpperInput: &Input{Rune: 'Y'},
        },
        {
            LowerLabel: "u",
            UpperLabel: "U",
            LowerInput: &Input{Rune: 'u'},
            UpperInput: &Input{Rune: 'U'},
        },
        {
            LowerLabel: "i",
            UpperLabel: "I",
            LowerInput: &Input{Rune: 'i'},
            UpperInput: &Input{Rune: 'I'},
        },
        {
            LowerLabel: "o",
            UpperLabel: "O",
            LowerInput: &Input{Rune: 'o'},
            UpperInput: &Input{Rune: 'O'},
        },
        {
            LowerLabel: "p",
            UpperLabel: "P",
            LowerInput: &Input{Rune: 'p'},
            UpperInput: &Input{Rune: 'P'},
        },
        {
            LowerLabel: "[",
            UpperLabel: "{",
            LowerInput: &Input{Rune: '['},
            UpperInput: &Input{Rune: '{'},
        },
        {
            LowerLabel: "]",
            UpperLabel: "}",
            LowerInput: &Input{Rune: ']'},
            UpperInput: &Input{Rune: '}'},
        },
        {
            LowerLabel: "\\",
            UpperLabel: "|",
            LowerInput: &Input{Rune: '\\'},
            UpperInput: &Input{Rune: '|'},
        },
    },
    {
        {
            LowerLabel: "a",
            UpperLabel: "A",
            LowerInput: &Input{Rune: 'a'},
            UpperInput: &Input{Rune: 'A'},
        },
        {
            LowerLabel: "s",
            UpperLabel: "S",
            LowerInput: &Input{Rune: 's'},
            UpperInput: &Input{Rune: 'S'},
        },
        {
            LowerLabel: "d",
            UpperLabel: "D",
            LowerInput: &Input{Rune: 'd'},
            UpperInput: &Input{Rune: 'D'},
        },
        {
            LowerLabel: "f",
            UpperLabel: "F",
            LowerInput: &Input{Rune: 'f'},
            UpperInput: &Input{Rune: 'F'},
        },
        {
            LowerLabel: "g",
            UpperLabel: "G",
            LowerInput: &Input{Rune: 'g'},
            UpperInput: &Input{Rune: 'G'},
        },
        {
            LowerLabel: "h",
            UpperLabel: "H",
            LowerInput: &Input{Rune: 'h'},
            UpperInput: &Input{Rune: 'H'},
        },
        {
            LowerLabel: "j",
            UpperLabel: "J",
            LowerInput: &Input{Rune: 'j'},
            UpperInput: &Input{Rune: 'J'},
        },
        {
            LowerLabel: "k",
            UpperLabel: "K",
            LowerInput: &Input{Rune: 'k'},
            UpperInput: &Input{Rune: 'K'},
        },
        {
            LowerLabel: "l",
            UpperLabel: "L",
            LowerInput: &Input{Rune: 'l'},
            UpperInput: &Input{Rune: 'L'},
        },
        {
            LowerLabel: ";",
            UpperLabel: ":",
            LowerInput: &Input{Rune: ';'},
            UpperInput: &Input{Rune: ':'},
        },
        {
            LowerLabel: `'`,
            UpperLabel: `"`,
            LowerInput: &Input{Rune: '\''},
            UpperInput: &Input{Rune: '"'},
        },
        {
            LowerLabel: "Enter",
            UpperLabel: "ENTER",
            LowerInput: &Input{Key: ebiten.KeyEnter},
            UpperInput: &Input{Key: ebiten.KeyEnter},
        },
    },
    {
        {
            LowerLabel: "Shift",
            UpperLabel: "SHIFT",
            LowerInput: &Input{Key: ebiten.KeyShift},
            UpperInput: &Input{Key: ebiten.KeyShift},
        },
        {
            LowerLabel: "z",
            UpperLabel: "Z",
            LowerInput: &Input{Rune: 'z'},
            UpperInput: &Input{Rune: 'Z'},
        },
        {
            LowerLabel: "x",
            UpperLabel: "X",
            LowerInput: &Input{Rune: 'x'},
            UpperInput: &Input{Rune: 'X'},
        },
        {
            LowerLabel: "c",
            UpperLabel: "C",
            LowerInput: &Input{Rune: 'c'},
            UpperInput: &Input{Rune: 'C'},
        },
        {
            LowerLabel: "v",
            UpperLabel: "V",
            LowerInput: &Input{Rune: 'v'},
            UpperInput: &Input{Rune: 'V'},
        },
        {
            LowerLabel: "b",
            UpperLabel: "B",
            LowerInput: &Input{Rune: 'b'},
            UpperInput: &Input{Rune: 'B'},
        },
        {
            LowerLabel: "n",
            UpperLabel: "N",
            LowerInput: &Input{Rune: 'n'},
            UpperInput: &Input{Rune: 'N'},
        },
        {
            LowerLabel: "m",
            UpperLabel: "M",
            LowerInput: &Input{Rune: 'm'},
            UpperInput: &Input{Rune: 'M'},
        },
        {
            LowerLabel: ",",
            UpperLabel: "<",
            LowerInput: &Input{Rune: ','},
            UpperInput: &Input{Rune: '<'},
        },
        {
            LowerLabel: ".",
            UpperLabel: ">",
            LowerInput: &Input{Rune: '.'},
            UpperInput: &Input{Rune: '>'},
        },
        {
            LowerLabel: "/",
            UpperLabel: "?",
            LowerInput: &Input{Rune: '/'},
            UpperInput: &Input{Rune: '?'},
        },
    },
    {
        {
            LowerLabel: "Space",
            UpperLabel: "SPACE",
            LowerInput: &Input{Rune: ' '},
            UpperInput: &Input{Rune: ' '},
        },
    },
}

type Input

Input represents the input event from a key press.

type Input struct {
    Rune rune
    Key  ebiten.Key
}

func (*Input) String

func (i *Input) String() string

type Key

Key represents a virtual key.

type Key struct {
    LowerLabel string
    UpperLabel string
    LowerInput *Input
    UpperInput *Input
    // contains filtered or unexported fields
}

type Keyboard

Keyboard is an on-screen keyboard widget.

type Keyboard struct {
    // contains filtered or unexported fields
}

func NewKeyboard

func NewKeyboard() *Keyboard

NewKeyboard returns a new Keyboard widget.

func (*Keyboard) AppendInput

func (k *Keyboard) AppendInput(events []*Input) []*Input

AppendInput appends user input that was received since the function was last called.

func (*Keyboard) Draw

func (k *Keyboard) Draw(target *ebiten.Image)

Draw draws the widget on the provided image. This function is called by Ebitengine.

func (*Keyboard) GetKeys

func (k *Keyboard) GetKeys() [][]*Key

GetKeys returns the keys of the keyboard.

func (*Keyboard) Hide

func (k *Keyboard) Hide()

Hide hides the widget.

func (*Keyboard) Hit

func (k *Keyboard) Hit(key *Key)

Hit handles a key press.

func (*Keyboard) SetAllowUserHide

func (k *Keyboard) SetAllowUserHide(allow bool)

SetAllowUserHide sets a flag that controls whether the widget may be hidden by the user.

func (*Keyboard) SetAlpha

func (k *Keyboard) SetAlpha(alpha float64)

SetAlpha sets the transparency level of the widget on a scale of 0 to 1.0.

func (*Keyboard) SetHideShortcuts

func (k *Keyboard) SetHideShortcuts(shortcuts []ebiten.Key)

SetHideShortcuts sets the key shortcuts which, when pressed, will hide the keyboard.

func (*Keyboard) SetKeys

func (k *Keyboard) SetKeys(keys [][]*Key)

SetKeys sets the keys of the keyboard.

func (*Keyboard) SetLabelFont

func (k *Keyboard) SetLabelFont(face font.Face)

SetLabelFont sets the key label font.

func (*Keyboard) SetPassThroughPhysicalInput

func (k *Keyboard) SetPassThroughPhysicalInput(pass bool)

SetPassThroughPhysicalInput sets a flag that controls whether physical keyboard input is passed through to the widget's input buffer. This is not enabled by default.

func (*Keyboard) SetRect

func (k *Keyboard) SetRect(x, y, w, h int)

SetRect sets the position and size of the widget.

func (*Keyboard) Show

func (k *Keyboard) Show()

Show shows the widget.

func (*Keyboard) Update

func (k *Keyboard) Update() error

Update handles user input. This function is called by Ebitengine.

func (*Keyboard) Visible

func (k *Keyboard) Visible() bool

Visible returns whether the widget is currently shown.

Subdirectories

Name Synopsis
..
demos
kibodo
game
mobile