Documentation ¶
Overview ¶
Package kibodo provides an on-screen keyboard widget for Ebitengine.
Index ¶
- Variables
- type Input
- type Key
- type Keyboard
- func (k *Keyboard) AppendInput(events []*Input) []*Input
- func (k *Keyboard) Draw(target *ebiten.Image)
- func (k *Keyboard) GetKeys() [][]*Key
- func (k *Keyboard) Hide()
- func (k *Keyboard) Hit(key *Key)
- func (k *Keyboard) Rect() image.Rectangle
- func (k *Keyboard) SetAllowUserHide(allow bool)
- func (k *Keyboard) SetAlpha(alpha float64)
- func (k *Keyboard) SetExtendedKeys(keys [][]*Key)
- func (k *Keyboard) SetHideShortcuts(shortcuts []ebiten.Key)
- func (k *Keyboard) SetKeys(keys [][]*Key)
- func (k *Keyboard) SetLabelFont(face font.Face)
- func (k *Keyboard) SetPassThroughPhysicalInput(pass bool)
- func (k *Keyboard) SetRect(x, y, w, h int)
- func (k *Keyboard) SetShowExtended(show bool)
- func (k *Keyboard) Show()
- func (k *Keyboard) Update() error
- func (k *Keyboard) Visible() bool
Constants ¶
This section is empty.
Variables ¶
var KeyToggleExtended = ebiten.Key(-10)
KeyToggleExtended is a sentinel key value. Any key with this value set will toggle the extended set of keys, if any defined via SetExtendedKeys.
var KeysMobileQWERTY = [][]*Key{ { { 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: "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: "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: "Backspace", UpperLabel: "BACKSPACE", LowerInput: &Input{Key: ebiten.KeyBackspace}, UpperInput: &Input{Key: ebiten.KeyBackspace}, }, }, { { LowerLabel: "Symbols", UpperLabel: "SYMBOLS", LowerInput: &Input{Key: KeyToggleExtended}, UpperInput: &Input{Key: KeyToggleExtended}, }, { LowerLabel: "?", UpperLabel: "!", LowerInput: &Input{Rune: '?'}, UpperInput: &Input{Rune: '!'}, }, { LowerLabel: "Space", UpperLabel: "SPACE", LowerInput: &Input{Rune: ' '}, UpperInput: &Input{Rune: ' '}, Wide: true, }, { LowerLabel: ".", UpperLabel: ",", LowerInput: &Input{Rune: '.'}, UpperInput: &Input{Rune: ','}, }, { LowerLabel: "Enter", UpperLabel: "ENTER", LowerInput: &Input{Key: ebiten.KeyEnter}, UpperInput: &Input{Key: ebiten.KeyEnter}, }, }, }
KeysMobileQWERTY is a QWERTY keyboard layout optimized for mobile devices.
var KeysMobileSymbols = [][]*Key{ { { LowerLabel: "1", UpperLabel: "1", LowerInput: &Input{Rune: '1'}, UpperInput: &Input{Rune: '1'}, }, { LowerLabel: "2", UpperLabel: "2", LowerInput: &Input{Rune: '2'}, UpperInput: &Input{Rune: '2'}, }, { LowerLabel: "3", UpperLabel: "3", LowerInput: &Input{Rune: '3'}, UpperInput: &Input{Rune: '3'}, }, { LowerLabel: "4", UpperLabel: "4", LowerInput: &Input{Rune: '4'}, UpperInput: &Input{Rune: '4'}, }, { LowerLabel: "5", UpperLabel: "5", LowerInput: &Input{Rune: '5'}, UpperInput: &Input{Rune: '5'}, }, { LowerLabel: "6", UpperLabel: "6", LowerInput: &Input{Rune: '6'}, UpperInput: &Input{Rune: '6'}, }, { LowerLabel: "7", UpperLabel: "7", LowerInput: &Input{Rune: '7'}, UpperInput: &Input{Rune: '7'}, }, { LowerLabel: "8", UpperLabel: "8", LowerInput: &Input{Rune: '8'}, UpperInput: &Input{Rune: '8'}, }, { LowerLabel: "9", UpperLabel: "9", LowerInput: &Input{Rune: '9'}, UpperInput: &Input{Rune: '9'}, }, { LowerLabel: "0", UpperLabel: "0", LowerInput: &Input{Rune: '0'}, UpperInput: &Input{Rune: '0'}, }, }, { { 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: "]", UpperLabel: "]", LowerInput: &Input{Rune: ']'}, UpperInput: &Input{Rune: ']'}, }, { 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: ")", UpperLabel: ")", LowerInput: &Input{Rune: ')'}, UpperInput: &Input{Rune: ')'}, }, { 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: "#", UpperLabel: "#", LowerInput: &Input{Rune: '#'}, UpperInput: &Input{Rune: '#'}, }, { 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: "&", UpperLabel: "&", LowerInput: &Input{Rune: '&'}, UpperInput: &Input{Rune: '&'}, }, { 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: "_", UpperLabel: "_", LowerInput: &Input{Rune: '_'}, UpperInput: &Input{Rune: '_'}, }, }, { { 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: "\"", UpperLabel: "\"", LowerInput: &Input{Rune: '"'}, UpperInput: &Input{Rune: '"'}, }, { 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: "?", UpperLabel: "?", LowerInput: &Input{Rune: '?'}, UpperInput: &Input{Rune: '?'}, }, { LowerLabel: "Backspace", UpperLabel: "BACKSPACE", LowerInput: &Input{Key: ebiten.KeyBackspace}, UpperInput: &Input{Key: ebiten.KeyBackspace}, }, }, { { LowerLabel: "Symbols", UpperLabel: "SYMBOLS", LowerInput: &Input{Key: KeyToggleExtended}, UpperInput: &Input{Key: KeyToggleExtended}, }, { LowerLabel: ",", UpperLabel: ",", LowerInput: &Input{Rune: ','}, UpperInput: &Input{Rune: ','}, }, { LowerLabel: "Space", UpperLabel: "SPACE", LowerInput: &Input{Rune: ' '}, UpperInput: &Input{Rune: ' '}, Wide: true, }, { LowerLabel: ".", UpperLabel: ".", LowerInput: &Input{Rune: '.'}, UpperInput: &Input{Rune: '.'}, }, { LowerLabel: "Enter", UpperLabel: "ENTER", LowerInput: &Input{Key: ebiten.KeyEnter}, UpperInput: &Input{Key: ebiten.KeyEnter}, }, }, }
KeysMobileSymbols is a symbols keyboard layout optimized for mobile devices.
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: ' '}, }, }, }
KeysQWERTY is a standard QWERTY keyboard layout.
Functions ¶
This section is empty.
Types ¶
type Input ¶
type Input struct { Rune rune Key ebiten.Key }
Input represents the input event from a key press.
type Key ¶
type Key struct { LowerLabel string UpperLabel string LowerInput *Input UpperInput *Input Wide bool // contains filtered or unexported fields }
Key represents a virtual key.
type Keyboard ¶
type Keyboard struct {
// contains filtered or unexported fields
}
Keyboard is an on-screen keyboard widget.
func (*Keyboard) AppendInput ¶
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 ¶
GetKeys returns the keys of the keyboard.
func (*Keyboard) Rect ¶ added in v1.0.2
Rect returns the position and size of the widget.
func (*Keyboard) SetAllowUserHide ¶
SetAllowUserHide sets a flag that controls whether the widget may be hidden by the user.
func (*Keyboard) SetAlpha ¶
SetAlpha sets the transparency level of the widget on a scale of 0 to 1.0.
func (*Keyboard) SetExtendedKeys ¶ added in v1.0.2
SetExtendedKeys sets the keys of the keyboard when the .
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 ¶
SetKeys sets the keys of the keyboard.
func (*Keyboard) SetLabelFont ¶
SetLabelFont sets the key label font.
func (*Keyboard) SetPassThroughPhysicalInput ¶
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 ¶
SetRect sets the position and size of the widget.
func (*Keyboard) SetShowExtended ¶ added in v1.0.2
SetShowExtended sets whether the normal or extended keyboard is shown.
func (*Keyboard) Update ¶
Update handles user input. This function is called by Ebitengine.