On-screen keyboard widget for ebiten
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

437 lines
8.1 KiB

2 months ago
package kibodo
import "github.com/hajimehoshi/ebiten/v2"
// KeysQWERTY is a standard QWERTY keyboard layout.
2 months ago
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",
2 months ago
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",
2 months ago
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: ' '},
},
},
2 months ago
}
var allKeys = []ebiten.Key{
ebiten.KeyA,
ebiten.KeyB,
ebiten.KeyC,
ebiten.KeyD,
ebiten.KeyE,
ebiten.KeyF,
ebiten.KeyG,
ebiten.KeyH,
ebiten.KeyI,
ebiten.KeyJ,
ebiten.KeyK,
ebiten.KeyL,
ebiten.KeyM,
ebiten.KeyN,
ebiten.KeyO,
ebiten.KeyP,
ebiten.KeyQ,
ebiten.KeyR,
ebiten.KeyS,
ebiten.KeyT,
ebiten.KeyU,
ebiten.KeyV,
ebiten.KeyW,
ebiten.KeyX,
ebiten.KeyY,
ebiten.KeyZ,
ebiten.KeyAltLeft,
ebiten.KeyAltRight,
ebiten.KeyArrowDown,
ebiten.KeyArrowLeft,
ebiten.KeyArrowRight,
ebiten.KeyArrowUp,
ebiten.KeyBackquote,
ebiten.KeyBackslash,
ebiten.KeyBackspace,
ebiten.KeyBracketLeft,
ebiten.KeyBracketRight,
ebiten.KeyCapsLock,
ebiten.KeyComma,
ebiten.KeyContextMenu,
ebiten.KeyControlLeft,
ebiten.KeyControlRight,
ebiten.KeyDelete,
ebiten.KeyDigit0,
ebiten.KeyDigit1,
ebiten.KeyDigit2,
ebiten.KeyDigit3,
ebiten.KeyDigit4,
ebiten.KeyDigit5,
ebiten.KeyDigit6,
ebiten.KeyDigit7,
ebiten.KeyDigit8,
ebiten.KeyDigit9,
ebiten.KeyEnd,
ebiten.KeyEnter,
ebiten.KeyEqual,
ebiten.KeyEscape,
ebiten.KeyF1,
ebiten.KeyF2,
ebiten.KeyF3,
ebiten.KeyF4,
ebiten.KeyF5,
ebiten.KeyF6,
ebiten.KeyF7,
ebiten.KeyF8,
ebiten.KeyF9,
ebiten.KeyF10,
ebiten.KeyF11,
ebiten.KeyF12,
ebiten.KeyHome,
ebiten.KeyInsert,
ebiten.KeyMetaLeft,
ebiten.KeyMetaRight,
ebiten.KeyMinus,
ebiten.KeyNumLock,
ebiten.KeyNumpad0,
ebiten.KeyNumpad1,
ebiten.KeyNumpad2,
ebiten.KeyNumpad3,
ebiten.KeyNumpad4,
ebiten.KeyNumpad5,
ebiten.KeyNumpad6,
ebiten.KeyNumpad7,
ebiten.KeyNumpad8,
ebiten.KeyNumpad9,
ebiten.KeyNumpadAdd,
ebiten.KeyNumpadDecimal,
ebiten.KeyNumpadDivide,
ebiten.KeyNumpadEnter,
ebiten.KeyNumpadEqual,
ebiten.KeyNumpadMultiply,
ebiten.KeyNumpadSubtract,
ebiten.KeyPageDown,
ebiten.KeyPageUp,
ebiten.KeyPause,
ebiten.KeyPeriod,
ebiten.KeyPrintScreen,
ebiten.KeyQuote,
ebiten.KeyScrollLock,
ebiten.KeySemicolon,
ebiten.KeyShiftLeft,
ebiten.KeyShiftRight,
ebiten.KeySlash,
ebiten.KeySpace,
ebiten.KeyTab,
ebiten.KeyAlt,
ebiten.KeyControl,
ebiten.KeyShift,
ebiten.KeyMeta,
ebiten.KeyMax,
}