code.witches.io/go/sdl2@v0.1.1/keyboard.go (about) 1 package sdl 2 3 // #include <SDL2/SDL_keyboard.h> 4 import "C" 5 import ( 6 "unsafe" 7 ) 8 9 type KeySymbol struct { 10 Scancode ScanCode 11 Keycode KeyCode 12 Modifiers KeyModifiers 13 } 14 15 func GetKeyboardState() []uint8 { 16 var numkeys int32 17 ptr := C.SDL_GetKeyboardState((*C.int)(unsafe.Pointer(&numkeys))) 18 ary := make([]uint8, numkeys) 19 copy(ary, unsafe.Slice((*uint8)(unsafe.Pointer(ptr)), numkeys)) 20 return ary 21 }