io/key: implement key.Release state

Implement key state for the following platforms:
js, wayland, windows, x11.

Unsupported platforms will continue to function as before, sending
key.Press for all key events.

Signed-off-by: Josiah Niedrauer <josiah@niedrauer.com>
This commit is contained in:
Josiah Niedrauer
2020-10-29 15:46:41 -07:00
committed by Elias Naur
parent ef652f4922
commit 42e568775c
7 changed files with 57 additions and 14 deletions
+10 -2
View File
@@ -228,9 +228,17 @@ func windowProc(hwnd syscall.Handle, msg uint32, wParam, lParam uintptr) uintptr
case windows.WM_ERASEBKGND:
// Avoid flickering between GPU content and background color.
return 1
case windows.WM_KEYDOWN, windows.WM_SYSKEYDOWN:
case windows.WM_KEYDOWN, windows.WM_KEYUP, windows.WM_SYSKEYDOWN, windows.WM_SYSKEYUP:
if n, ok := convertKeyCode(wParam); ok {
w.w.Event(key.Event{Name: n, Modifiers: getModifiers()})
e := key.Event{
Name: n,
Modifiers: getModifiers(),
State: key.Press,
}
if msg == windows.WM_KEYUP || msg == windows.WM_SYSKEYUP {
e.State = key.Release
}
w.w.Event(e)
}
case windows.WM_LBUTTONDOWN:
w.pointerButton(pointer.ButtonLeft, true, lParam, getModifiers())