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 KeyToggleExtended = ebiten.Key(-10)
KeysMobileQWERTY is a QWERTY keyboard layout optimized for mobile devices.
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: "Escape", UpperLabel: "ESCAPE", LowerInput: &Input{Key: ebiten.KeyEscape}, UpperInput: &Input{Key: ebiten.KeyEscape}, }, { LowerLabel: "Symbols", UpperLabel: "SYMBOLS", LowerInput: &Input{Key: KeyToggleExtended}, UpperInput: &Input{Key: KeyToggleExtended}, }, { 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 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: "Escape", UpperLabel: "ESCAPE", LowerInput: &Input{Key: ebiten.KeyEscape}, UpperInput: &Input{Key: ebiten.KeyEscape}, }, { LowerLabel: "Symbols", UpperLabel: "SYMBOLS", LowerInput: &Input{Key: KeyToggleExtended}, UpperInput: &Input{Key: KeyToggleExtended}, }, { 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}, }, }, }
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: ' '}, }, }, }
Input represents the input event from a key press.
type Input struct { Rune rune Key ebiten.Key }
func (i *Input) String() string
Key represents a virtual key.
type Key struct { LowerLabel string UpperLabel string LowerInput *Input UpperInput *Input Wide bool // contains filtered or unexported fields }
Keyboard is an on-screen keyboard widget.
type Keyboard struct {
// contains filtered or unexported fields
}
func NewKeyboard(f *sfnt.Font) *Keyboard
NewKeyboard returns a new Keyboard widget.
func (k *Keyboard) AppendInput(events []*Input) []*Input
AppendInput appends user input that was received since the function was last called.
func (k *Keyboard) Draw(target *ebiten.Image)
Draw draws the widget on the provided image. This function is called by Ebitengine.
func (k *Keyboard) GetKeys() [][]*Key
GetKeys returns the keys of the keyboard.
func (k *Keyboard) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
HandleMouse passes the specified mouse event to the on-screen keyboard.
func (k *Keyboard) Hide()
Hide hides the widget.
func (k *Keyboard) Hit(key *Key)
Hit handles a key press.
func (k *Keyboard) KeyAt(x, y int) *Key
KeyAt returns the key located at the specified position, or nil if no key is found.
func (k *Keyboard) Rect() image.Rectangle
Rect returns the position and size of the widget.
func (k *Keyboard) SetAlpha(alpha float64)
SetAlpha sets the transparency level of the widget on a scale of 0 to 1.0.
func (k *Keyboard) SetExtendedKeys(keys [][]*Key)
SetExtendedKeys sets the keys of the keyboard when the .
func (k *Keyboard) SetHideShortcuts(shortcuts []ebiten.Key)
SetHideShortcuts sets the key shortcuts which, when pressed, will hide the keyboard. Defaults to the Escape key.
func (k *Keyboard) SetKeys(keys [][]*Key)
SetKeys sets the keys of the keyboard.
func (k *Keyboard) SetLabelFont(face font.Face)
SetLabelFont sets the key label font.
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 (k *Keyboard) SetRect(x, y, w, h int)
SetRect sets the position and size of the widget.
func (k *Keyboard) SetScheduleFrameFunc(f func())
SetScheduleFrameFunc sets the function called whenever the screen should be redrawn.
func (k *Keyboard) SetShowExtended(show bool)
SetShowExtended sets whether the normal or extended keyboard is shown.
func (k *Keyboard) Show()
Show shows the widget.
func (k *Keyboard) Update() error
Update handles user input. This function is called by Ebitengine.
func (k *Keyboard) Visible() bool
Visible returns whether the widget is currently shown.