Type a keystroke with modifiers

As I don't use CAPS LOCK at all, I use KM to map "This device key: ... is down" to "Type the Delete Keystroke".
Unluckily this does not pass through any modifiers.

I would love to have an option to use the currently pressed modifier within the macro.
So instead of having a macro for every possible modifier combination I'd just have to write one macro that dynamically adapts according to the pressed modifiers.

In KM you can indeed create conditions that depend upon modifiers. But CapsLock is not a Modifier in the traditional sense.

However, you can map any modifier to the CapsLock key (System Preferences > Keyboard > Button “Modifier Keys…”), and then you can us the CapsLock regularly as modifier condition.

Wow that's interesting, Jan. By using "is down" you can actually get Caps Lock to act like an auto-repeating delete button!! But when you switch to "is pressed" you lose the auto-repeat. That's very interesting. Thanks for sharing that.

However even when I created a test in KM to test whether a modifier was being pressed at the same time, it wouldn't detect the modifier. This is either a macOS limitation or possibly even a hardware limitation.

But I was able to "not-quite-achieve" your goal by reversing something. If I made the delete key out of the Option button and used the CAPS LOCK state as the modifier, I was able to have the option key act as a Delete Forward key which can autorepeat or a Delete Word key which also autorepeats. But this only worked if I put a short beep after one of the two keys, as shown below:

Replacing the beep with a Pause did NOT work at all. It had to be a beep. I have no idea why that is. I'd like one of the wizards here to explain why replacing the beep with a pause causes this macro to fail. This is really unexpected behaviour.

I think I've learned here that modifiers are detectable as hotkeys, but using multiple modifiers at the same time (unless the second one is the caps lock modifier, which is probably because apart from being a modifier it's also a dual-purpose "state") is not detectable.

However there's a third option which Tom didn't mention. Using the Preferences panel he mentions, you can map the Escape key to the Caps Lock key. This will mean that the Caps Lock button becomes an escape key. Modifiers will work with that key. Now this might mean that you will lose your escape key as a separate key HOWEVER many new MacBooks do not have an Escape key at all so this may not be a loss. (I found the link before after I wrote this paragraph.)

Thanks for the suggestions.
I think I've not explained my problem clearly.

This is my macro:

When I press CAPS LOCK it perfectly translates to Delete.
My issue is that I can either "ignore modifiers" which results in Cmd + CL in being Delete or I can use "with these modifiers" and write a macro for Cmd + CL to be Cmd + Delete. But I would have to write a macro for Alt, Ctrl, Shift and every combination of these four modifiers.

What I would like to have is writing one macro (without if/else) where the currently pressed modifiers are applied to the remapped Delete key.

Something like "ignoring modifiers but applying to actions" in the triggers or an action "type pressed modifiers".

When you say "I would like to have... one macro (without if/else) where the currently pressed modifiers are applied to the remapped Delete key." I think what you want is to perform the following function:

  1. CAPS LOCK => Delete
  2. CMD-CAPS LOCK => CMD-Delete
  4. CTRL-CAPS LOCK => CTRL-Delete

Is that what you are trying to achieve? This is how I would word "the goal" because it doesn't involve talking about KM at all.

If so, I don't think KM works that way. As you indicated, four separate macros will work fine, and I think that's what you will require. But I'm right only 80% of the time. Maybe a wizard on this website will correct me, but I don't think so.

P.S. Make sure you use "is tapped (or is down)" instead of "is pressed" because the former will support autorepeat, and I think that's a good feature for a Delete key. However this form of autorepeat isn't controlled by the macOS autorepeat preference, so it may behave at a different speed based upon KM Engine speed, CPU load, and other factors. But for me it works at a nice speed.

P.S. Four short macros is not onerous. I've seen people who had a reason to create 80 macros, one for each key on the keyboard. And it still worked fine.

P.S. The autorepeat function I speak about works because multiple copies of this macro are being invoked. If they get invoked too fast, and by that I mean 25 copies running at the same time, the KM Engine will abort all the macros. That may not hurt you, because each macro is just performing the same function. In fact it could be happening right now and you wouldn't notice.

Yes, this summarizes my goal.

In my opinion, this could be a feature coming with KM hence a feature request (or a question if this feature exists).

Of course is it possible to create four or even more (cmd+alt+CL, alt+ctrl+CL, ...) macros.
But it's tedious and may be an easy feature to implement in KM.

On the other hand it may also require recursion as Delete may be trigger a macro itself, so it then would need to check the other macros first.
So possibly it's more relatable the way it is now. :thinking:

I see what you mean. But I wouldn't call that "recursion," since it's not calling itself. It's calling a different action. I would call that "nesting". Nothing wrong with nesting. On the other hand I've written macros that actually (and accidentally) triggered itself and that's a problem that took time to debug.

You can make all the feature requests you want, that's fine. I've made a couple of dozen myself and I think one or two got implemented!

Let me try to reword your feature request. Most people aren't aware of this but there's a low level feature in the USB world called "scan codes". At this low level, all keyboard keys are totally equal, including Caps Lock, Shift, alphabetics, and so on. I think what you want and are requesting is a "scan code remapper". Not many people really need that. Maybe that would help when converting a QWERTY to a QWERTZ keyboard, or maybe when wanting to swap CTRL and COMMAND keys. But macOS already allows some of this remapping through it's Keyboard Preferences window. You just happened to find a requirement that macOS doesn't support.

However even though most people don't need that, I think it's a fine idea for a product called "Keyboard Maestro." And I think it's possible. But the person who writes KM has to consider things like "how many people want a feature" and "how much work it is."

Yes, I guess that's how Karabiner works.
That's what I used until a potential keylogger was revealed.

For the meantime I've to stick with multiple macros.