Keyboard macros behavoir

Hi, I’m trying to bind a simple macro on a button.
Alt+U (collapse every group/track in ableton live).

The macro itself works, but seems to be activated both on button press and button de-press. I can’t find anything about it in the manual

My macro looks like this:

Sorry for autoquoting.
Post Scriptum
I also tried different combination of button press and de-press. Full press-depress for each one, just press, ecc ecc

You’ll want to use an ‘IF’ block:

if self:button_state() > 0 then
	keyboard_send(25, 1, 1, 4, 0, 2, 24, 1, 0, 4)
else
end

That exact bit of code sends ‘Alt + U’. Tested as working in Ableton. Use the above in a ‘</>Code Block’ in place of the ‘Keyboard’ Action Block.

What the above is saying is basically “If the button is pressed, execute my code or else do nothing”.

Cheers! :slight_smile:

1 Like

It works perfectly, thank you!
I wonder what’s the purpose of “keyboard action” since it doesn’t work as intended.
I haven’t any coding skill and I’m not be able to edit macros such as that :frowning:

1 Like

It generates the code required to send keyboard actions. It just does it in an easier to understand format. You have to remember that all button presses are, in fact, two events; one event on the press and one event on the release.

It certainly would be much easier if the UI element for any button action blocks included things like ‘On press’, ‘On release’, and ‘Both’. This way, the user could select which button event triggers the code. It gets a bit convoluted when a user needs to convert action blocks to code to modify the LUA so that it works as most people would want.

I don’t have these skills either other than having looked at coding briefly during various points in my life. For the Grid Editor, it’s fairly simple to see what’s going on. For example, I didn’t write this code snippet from scratch:
keyboard_send(25, 1, 1, 4, 0, 2, 24, 1, 0, 4)

I created a ‘Keyboard’ action block, added in the macro then converted the block ‘To code’. This way, the coding is done for you. :slight_smile: You can see exactly what each action block is doing when you convert it ‘To code’. I just happened to run in to the same issue when I was configuring an encoder press and learned the ‘IF’ statement that configures the behavior as I want.

I’ve only had my Grid controllers for a couple of weeks now and I’ve been able to do some stuff that’s not available to do in Action blocks. If you’re stuck, post your questions here or check out the Discord server. There’s a lot of people there that are willing to help out.

1 Like