macoskarabiner

track last pressed key


I want to map my mouse button to the last number key I pressed.

I thought about using variables to track the last number key that was pressed.

I tried

{  
   "from":{  
      "key_code":"0"
   },
   "to":[  
      {  
         "set_variable":{  
            "name":"last_number",
            "value":"0"
         }
      },
      {  
         "key_code":"0"
      }
   ],
   "type":"basic"
},
...
{  
   "conditions":[  
      {  
         "name":"last_number",
         "type":"variable_if",
         "value":"0"
      }
   ],
   "from":{  
      "modifiers":{  
         "optional":[  
            "any"
         ]
      },
      "pointing_button":"button4"
   },
   "to":[  
      {  
         "key_code":"0"
      }
   ],
   "type":"basic"
},
...

but the mouse button never outputs anything


Solution

  • Values have to be numbers, changing "0" to 0 fixed it