NAME
JSON::Karabiner::Manipulator::Actions::To - To action
SYNOPSIS
use JSON::Karabiner;
my $to_action = $manip_obj->add_action('to');
# Use methods to add data to the C<to> action:
$to_action->add_key_code('h', 'i', 'x');
$to_action->add_l_modifiers('control', 'left_shift');
# Other C<to> actions may be added as well:
my $to_alone_action = JSON::Karabiner->new('Title', 'file.json')->add_rule()->add_manipulator->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:
$to->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:
$to->add_key_code('h-L') # adds a "lazy" property to key code
$to->add_key_code('h-R') # adds a "repeat" property to key code
$to->add_key_code('h-H') # adds a "halt" property to key code
$to->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:
$to->add_consumer_key_code('MUSIC_NEXT');
add_pointing_button($value)
Add a pointing_button
property to a from
action:
$to->add_pointing_button('button2');
add_shell_command($command)
Add a shell_command
property to a to
action:
$to->add_shell_command('ls');
add_select_input_source($option, $value)
Add a select_input_source
property to a to
action:
$to->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:
$to->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:
$to->add_set_variable('some_variable', '0');
add_mouse_key($name, $value)
Add a mouse_key
property to a to
action:
$to->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:
$to->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 your modifiers.
VERSION
version 0.008
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.