class RuKeyboard
Public Instance Methods
press_key(key)
click to toggle source
# File lib/rukeyboard.rb, line 4 def press_key key raise NotImplementedError end
release_key(key)
click to toggle source
# File lib/rukeyboard.rb, line 8 def release_key key raise NotImplementedError end
tap_key(key, n = 1)
click to toggle source
# File lib/rukeyboard.rb, line 12 def tap_key key, n = 1 n.times do press_key key release_key key end end
type_string(str, interval=0)
click to toggle source
# File lib/rukeyboard.rb, line 19 def type_string str, interval=0 str.chars.each do |ch| sleep interval tap_key ch end end
Private Instance Methods
event(key, press)
click to toggle source
# File lib/rukeyboard/darwin.rb, line 49 def event key, press code = CGEvent::CHARS[key.downcase] return if code.nil? event = CGEvent::CGEventCreateKeyboardEvent nil, code, press CGEvent::CGEventPost :kCGHIDEventTap, event CGEvent::CFRelease event end