lib/fusuma/plugin/sendkey/keyboard.rb in fusuma-plugin-sendkey-0.13.0 vs lib/fusuma/plugin/sendkey/keyboard.rb in fusuma-plugin-sendkey-0.13.1
- old
+ new
@@ -8,11 +8,11 @@
module Fusuma
module Plugin
module Sendkey
# Emulate Keyboard
class Keyboard
- INTERVAL = 0.03
+ KEY_INTERVAL = 0.03
MODIFIER_KEY_CODES = %w[
KEY_CAPSLOCK
KEY_LEFTALT
KEY_LEFTCTRL
@@ -82,12 +82,11 @@
param_to_codes(clear)
end
clear_modifiers(clear_keycodes - param_keycodes)
- type_keycodes.each { |keycode| keydown(keycode) && key_sync }
- sleep(INTERVAL)
- type_keycodes.reverse_each { |keycode| keyup(keycode) && key_sync }
+ type_keycodes.each { |keycode| keydown(keycode) && key_sync && sleep(KEY_INTERVAL) }
+ type_keycodes.reverse_each { |keycode| keyup(keycode) && key_sync && sleep(KEY_INTERVAL) }
end
def keydown(keycode)
send_event(code: keycode, press: true)
end