keyboard

package
v0.41.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2020 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsMacOSModifiers

func AsMacOSModifiers(keycode glfw.Key) (int, bool)

AsMacOSModifiers translate the keycode to the ModifierKey

func DetectTextInputDoneMod

func DetectTextInputDoneMod(mods glfw.ModifierKey) bool

DetectTextInputDoneMod returns true if the modifiers pressed indicate the typed text can be committed

func DetectWordMod

func DetectWordMod(mods glfw.ModifierKey) bool

DetectWordMod returns true if the modifiers pressed correspond to the word movement modifier

func ToMacOSKeyCode

func ToMacOSKeyCode(keycode glfw.Key, scancode int) int

ToMacOSKeyCode takes a glfw keyCode and return his MacOS equivalent / MacOS doesn't provide a scan code, but a virtual keycode to represent a

physical key.
We first try to convert the physical key to the virtual keycode and then
return the MacOS keycode version of this key.
If we fail to get the virtual keycode, map the physical GLFW keycode to the
MacOS on.

func ToMacOSModifiers

func ToMacOSModifiers(mods glfw.ModifierKey) (macOSmods int)

ToMacOSModifiers takes a glfw ModifierKey and return his MacOS equivalent as defined in https://github.com/flutter/flutter/blob/3e63411256cc88afc48044aa5ea06c5c9c6a6846/packages/flutter/lib/src/services/raw_keyboard_macos.dart#L241

Types

type Event

type Event struct {
	// Common
	Keymap    string `json:"keymap"` // Linux/MacOS switch
	Character string `json:"character"`
	KeyCode   int    `json:"keyCode"`
	Modifiers int    `json:"modifiers"`
	Type      string `json:"type"`

	// Linux
	Toolkit             string `json:"toolkit,omitempty"`
	ScanCode            int    `json:"scanCode,omitempty"`
	UnicodeScalarValues uint32 `json:"unicodeScalarValues,omitempty"`

	// MacOS
	CharactersIgnoringModifiers string `json:"charactersIgnoringModifiers,omitempty"`
	Characters                  string `json:"characters,omitempty"`
}

Event corresponds to a Flutter (dart) compatible RawKeyEventData keyevent data. Multi-platform keycode translation is handled withing this package.

As input, go-flutter gets GLFW-keyevent who are only compatible with RawKeyEventDataLinux. To fully support keyboard shortcut (like Command+C to copy on darwin), the flutter framework expect the sent keyevent data to be in the form of a RawKeyEventDataMacOs keyevent data. This package maps the GLFW key-codes to the MacOS ones.

On the flutter framework side:

RawKeyEventDataMacOs data is received for darwin
RawKeyEventDataLinux data is received for linux and windows

func Normalize

func Normalize(key glfw.Key, scancode int, mods glfw.ModifierKey, action glfw.Action) (event Event, err error)

Normalize takes a GLFW-based key and normalizes it by converting the input to a keyboard.Event struct compatible with Flutter for the current OS.

RawKeyEventDataMacOs data for darwin
RawKeyEventDataLinux data for linux and windows

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL