Class: Delirium::Platform::Darwin::Keyboard

Inherits:
Base::Keyboard show all
Defined in:
lib/delirium/platform/darwin/keyboard.rb

Instance Method Summary collapse

Instance Method Details

#key_down(key:) ⇒ Object



24
25
26
# File 'lib/delirium/platform/darwin/keyboard.rb', line 24

def key_down(key:)
  `cliclick kd:#{key}`
end

#key_press(key:) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/delirium/platform/darwin/keyboard.rb', line 5

def key_press(key:)
  case key
  when String
    `cliclick t:#{key}`
  when Symbol
    cliclick_key = case key
    when :cmd
    when :volume_up
      "volume-up"
    when :volume_down
      "volume-down"
    else
      key
    end

    `cliclick kp:#{cliclick_key}` if cliclick_key
  end
end

#key_up(key:) ⇒ Object



28
29
30
# File 'lib/delirium/platform/darwin/keyboard.rb', line 28

def key_up(key:)
  `cliclick ku:#{key}`
end

#write(string:) ⇒ Object



32
33
34
# File 'lib/delirium/platform/darwin/keyboard.rb', line 32

def write(string:)
  `cliclick t:#{string}`
end