NAME

JSON::Karabiner::Manipulator::Actions::To - To action object

SYNOPSIS

  add_action 'to';

  # Use methods to add data to the C<to> action:
  add_key_code 'h', 'i', 'x';
  add_modifiers 'control', 'left_shift';

  # Other "to" actions may be added as well:

  add_action 'to_if_alone';

DESCRIPTION

The To actions describe what Karbiner will do when the from action associated with the to action is triggered. For example, you may want Karbiner to execute a shell script if control-shift-h is pressed.

Below are the methods used to add data to the to action. Note that the methods below also apply to the other to actions (to_if_alone, to_after_key_up, etc.)

Consult the official Karbiner documentation about the to data structure.

new($type)

The constructor method is not called directly. The to action object is more typically created via the manipulator object's add_action() method.

add_key_code(@values)

Add a key_code property to a to action:

  add_key_code 'h', 'i', 'x';

Special properties for key codes (lazy, repeat, halt and hold_down_millisecond can be attached with the following special notation:

  add_key_code 'h-L'   # adds a "lazy" property to key code
  add_key_code 'h-R'   # adds a "repeat" property to key code
  add_key_code 'h-H'   # adds a "halt" property to key code
  add_key_code 'h-200' # adds a "hold_down_milliseconds" property to the key
                        # code with the value set to the number specified after the dash

add_consumer_key_code($value)

Add a consumer_key_code property to a from action:

  add_consumer_key_code 'MUSIC_NEXT';

add_pointing_button($value)

Add a pointing_button property to a from action:

  add_pointing_button 'button2';

add_shell_command($command)

Add a shell_command property to a to action:

  add_shell_command 'ls';

add_select_input_source($option, $value)

Add a select_input_source property to a to action:

  select_input_source 'language', 'language regex';

Multiple option/value pairs may be set by calling this method multiple times.

https://karabiner-elements.pqrs.org/docs/json/complex-modifications-manipulator-definition/to/select-input-source/

add_select_input_source($option, $value)

Add a select_input_source property to a to action:

  add_select_input_source 'language', 'language regex';

Multiple option/value pairs may be set by calling this method multiple times.

add_set_variable($name, $value)

Add a set_value property to a to action:

  add_set_variable 'some_variable', '1';

add_mouse_key($name, $value)

Add a mouse_key property to a to action:

  add_mouse_key 'speed_multiplier', '1.0';

Multiple name/value pairs may be set by calling this method multiple times.

https://karabiner-elements.pqrs.org/docs/json/complex-modifications-manipulator-definition/to/mouse-key/

add_modifiers(@modifiers)

Add a modifiers property to a keys in a to action:

  add_modifiers 'left_shift', 'left_command';

The modifiers can only be applied to the last key/buttons added to the object. In other words, if you need to apply to modifier to more than one key, add the keys that require modifiers individually and then add the modifiers.

VERSION

version 0.018

AUTHOR

Steve Dondley <s@dondley.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2020 by Steve Dondley.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.