Skip to main content

rule()

Use rule() to create a group of manipulators.

rule('Demo').manipulators([
map(1).to(2),
])
Generated JSON in profiles.complex_modifications.rules
{
"description": "Demo",
"manipulators": [
{
"type": "basic",
"from": { "key_code": "1" },
"to": [ { "key_code": "2" } ]
}
]
}

Conditions added to rule() will be added to all manipulators in the group.

rule('Demo', ifVar('test')).manipulators([
map(1).to(2),
]) // or rule().condition()
Generated JSON in profiles.complex_modifications.rules
{
"description": "Demo",
"manipulators": [
{
"type": "basic",
"from": { "key_code": "1" },
"to": [ { "key_code": "2" } ],
"conditions": [
{ "type": "variable_if", "name": "test", "value": 1 }
]
}
]
}
warning

manipulators() cannot be empty in a rule.