-
Notifications
You must be signed in to change notification settings - Fork 53
Callbacks
HASUMI Hitoshi edited this page May 22, 2023
·
5 revisions
Feature | Version | When it runs |
---|---|---|
Keyboard#before_report |
0.9.0+ | Every time a key tapped |
Keyboard#output_report_changed |
0.9.14+ | When the status of "Num Lock", "Caps Lock" and "Scroll Lock" in the host device is changed |
Keyboard#on_start |
0.9.18+ | On start up of the keyboard |
Keyboard#signal_partner |
0.9.18+ | When a specific key is tapped |
Callbacks are kind of hook methods to get called at certain moments of the keyboard's event.
Take a good look at the difference in parameters.
# Neither method parameter nor block parameter
kbd.before_report do |keyboard|
# Do something
end
# Gets a block variable `output`
kbd.output_report_changed do |output|
# Do something
end
# Neither method parameter nor block parameter
kbd.on_start do |keyboard|
# Do something
end
# Takes a parameter (`:KEYCODE` in this case) before the block
kbd.signal_partner :KEYCODE do |keyboard|
# Do something on the partner half when :KEYCODE is tapped
# Naturally, this works only if kbd.split == true
end
You can find examples on Sounder and Num Lock, Caps Lock and Scroll Lock.
- Getting started
- Keyboard features
- Keycodes (ja)
- Mouse (ja)
- Layers and mode key (ja)
- Debounce
- Composite key
- Split-type keyboard
- Keyscan matrix
- Num Lock, Caps Lock and Scroll Lock
- Useful methods that make you free
- BIOS mode
- Other features
- Examples
- Development
- Contribute to the Wiki
- FAQ