JSON::Karabiner::Manipulator::Actions::To - To action object
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';
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.
To
from
to
control-shift-h
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.)
to_if_alone
to_after_key_up
Consult the official Karbiner documentation about the to data structure.
The constructor method is not called directly. The to action object is more typically created via the manipulator object's add_action() method.
add_action()
Add a key_code property to a to action:
key_code
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:
lazy
repeat
halt
hold_down_millisecond
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 a consumer_key_code property to a from action:
consumer_key_code
add_consumer_key_code 'MUSIC_NEXT';
Add a pointing_button property to a from action:
pointing_button
add_pointing_button 'button2';
Add a shell_command property to a to action:
shell_command
add_shell_command 'ls';
Add a select_input_source property to a to action:
select_input_source
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 'language', 'language regex';
Add a set_value property to a to action:
set_value
add_set_variable 'some_variable', '1';
Add a mouse_key property to a to action:
mouse_key
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 a modifiers property to a keys in a to action:
modifiers
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 0.018
Steve Dondley <s@dondley.com>
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.
To install JSON::Karabiner, copy and paste the appropriate command in to your terminal.
cpanm
cpanm JSON::Karabiner
CPAN shell
perl -MCPAN -e shell install JSON::Karabiner
For more information on module installation, please visit the detailed CPAN module installation guide.