Class: Mac::EventMonitor::KeyboardEvent

Inherits:
Event
  • Object
show all
Defined in:
lib/mac-event-monitor/event/keyboard_event.rb

Instance Attribute Summary collapse

Attributes inherited from Event

#location, #time, #type

Instance Method Summary collapse

Methods inherited from Event

create_from_description, parse_location

Methods included from JsonSerializable

included, #to_json

Constructor Details

#initialize(type, time, location, keycode, flags) ⇒ KeyboardEvent

Returns a new instance of KeyboardEvent.



6
7
8
9
10
11
# File 'lib/mac-event-monitor/event/keyboard_event.rb', line 6

def initialize(type, time, location, keycode, flags)
  super(type, time, location)

  @keycode = keycode.to_i
  @flags   = flags.to_i(16)
end

Instance Attribute Details

#flagsObject (readonly)

Returns the value of attribute flags.



4
5
6
# File 'lib/mac-event-monitor/event/keyboard_event.rb', line 4

def flags
  @flags
end

#keycodeObject (readonly)

Returns the value of attribute keycode.



4
5
6
# File 'lib/mac-event-monitor/event/keyboard_event.rb', line 4

def keycode
  @keycode
end

Instance Method Details

#alt_key?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/mac-event-monitor/event/keyboard_event.rb', line 21

def alt_key?
  check_flag(19)
end

#command_key?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/mac-event-monitor/event/keyboard_event.rb', line 25

def command_key?
  check_flag(20)
end

#ctrl_key?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/mac-event-monitor/event/keyboard_event.rb', line 17

def ctrl_key?
  check_flag(18)
end

#dataObject



41
42
43
# File 'lib/mac-event-monitor/event/keyboard_event.rb', line 41

def data
  super + [keycode, flags.to_s(16)]
end

#function_key?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/mac-event-monitor/event/keyboard_event.rb', line 37

def function_key?
  check_flag(23)
end

#help_key?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/mac-event-monitor/event/keyboard_event.rb', line 33

def help_key?
  check_flag(22)
end

#num_pad_key?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/mac-event-monitor/event/keyboard_event.rb', line 29

def num_pad_key?
  check_flag(21)
end

#shift_key?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/mac-event-monitor/event/keyboard_event.rb', line 13

def shift_key?
  check_flag(16) || check_flag(17)
end