How to Chord Words?

It's funny, there's some math where I just look at it and it makes sense, and other stuff where it doesn't click and the explanations have never made it click. Calculus made sense to me, permutations and combinations mostly made sense. Differential equations and matrix algebra were why I dropped out of Physics and switched to Computer Science -- I could follow it in class and could not generate it in the homework if my life depended on it.

This thread has developed a lot further, but I just stumbled over your question above: As you experience, KM is not differenciating between your trigger combinations because of the word „any“: ANY of the following will trigger… so your macro will trigger with any pressed a as well with any long pressed v, it does not care for the combination. If you want to control the combination, you‘ll have to use setups like Peternlewis explained (and did not recommend).
Probably not helpful at this moment now, but always to be kept in mind. :nerd_face:

1 Like

Back to the OP and "chording".

I've been experimenting with this. So far I have a macro that is triggered by the V key being tapped which then simply types the "V" keystroke, and another macro that is triggered by a long-press of the V key, that now activates a second group for one action.

In that second group I can have single keys, normal text keys, trigger all sorts of things, from text to text window displays and app opening. It's not really chording, I have to release the long-press "V" before I type the second key. Here I used a Stickies window and did a bunch of experimenting with whether I could type Vs and As as I expected to be able to, interspersed with long presses of the V key followed by various keys, including the A key.

image

I had the A key trigger a display window.

image

Here's the first Macro group, containing two macros, one that activates the other group using the longpress trigger and the other that types normal text in response to a normal press:

image

Here's the Group Toggle Macro:

image

And here's the one that just types text:

image

The second group is enabled, but only activated for one action, without specifying what triggers that.

image

It gets activated by the Group Toggle macro above. This group contains the macros that actually do things, like the one that responds to the A key:

image

So I can type along normally and not notice anything going until I do a long press of the V key. Then the next character doesn't type anything, and IF I have defined it to be a trigger, like I did for the A key, then it can execute the associated macro.

Using the long press to activate a whole set of single letter hotkeys, while the short press or tap is normally typed text, that does seem like it would have possibilities it typing combination modifier keystrokes (e.g., "⌃⇧⌥V" is just too cumbersome and slow.

I imagine, not having tried this kind of speed typing before, that a long-press "T" could set up a whole set of T-words where the single text key hotkey following would be the final letter of the common word. So LongT,e would type "the", LongT,m would type "them", LongT,n would type "then", LongT,y would type "they", LongT,s would type "this", etc., etc. Of course not holding the T key long enough would result in a typo, so that would take some practice since the goal is speed.

To program it in KBM, I might have a single macro for all the varioius options that would follow a LongT, where all of those letters are triggers for the macro. Then I would use a Switch action, switching on the value of the %TriggerValue% token, to determine which set of actions would be performed in response to each defined trigger of that single macro.

If I understand correctly, "v" is typed when you tap the key briefly, so, when "v" is released?

The action trigger says:
image

I would presume that the actual exact trigger point depends on the release, since until then you don't know if it's a long press or not. Exactly how this is implemented, I don't know; that's a question for @peternlewis.

The logic is simple, "v" is typed when the key is released. The key must be pressed and released within a certain (short) time. This is what is called short pressed.

With long presses there are two possibilities. Either something is triggered when a key is pressed and held for longer than short pressed. In other words, something is triggered when the key is down. Or you have to release the key first. That doesn't matter. The problem is always the same.

In my eternal search for a solution to this problem, I sometimes hope that someone has had an idea that I haven't thought of. But there is no such idea. It's like trying to invent a perpetual motion machine.

There may be two reasons why this works for you. It doesn't work for me for exactly one reason ... but I don't want to talk you into a problem that you don't have. :slightly_smiling_face:

For exact details, I have to defer to Peter (@peternlewis), but my interpretation and reasoning about it is that starting a timer when the key is pressed and then having a trigger go off if the key is still down when the timer ends, would be an awkward way to implement a long-press trigger because the timer is the trigger, not the key. I suspect that the way it works is that the timer starts at the keypress or the keypress start microsecond is saved and then nothing happens until the key is released, at which point the timer is checked or the current microsecond is compared with the keypress start microsecond. Either way, it's the key release that initiates the trigger, not the internal timer. That's my guess. Peter is the authority on how KBM and MacOS implement short vs long press of a key.

I got it partially working in some brief experimenting. In every case that I tried, the first key had to be released first to be able to set the context for the second key. That's simply the limits of my imagination and experimentation, and it produced something that could be, it seems to me, be potentially useful.

But what I came up with is still not the chord that you're trying to achieve.

There may indeed be a way. There has been at least one time where people, including Peter, said that something couldn't be done, and I figured out a way, because I kept thinking about it because it really mattered to me to make it work and I kept trying things. And there have been other things where I haven't been able to figure anything out so far, so I've been looking instead for workarounds, trying to identify exactly what it is that I'm trying to do and seeing how close I can get with things that still help me do things at least close to the way that I want to.

I'm not actually trying to use the technique that I came up with, it's a first approximation at what might eventually be a solution, or not. So I'm still curious about what works and what doesn't work for you.

I think I understand better now what you're trying to do. And yes, it seems to be exactly what I'm trying to do. It has nothing to do with "chording". It's about short/long pressing a key (a letter, without modifier) to trigger two different actions. Right?

In your case: If you only tap "v" briefly, "v" is typed and if you hold down "v" for longer and release it, a different action is triggered. But: Both actions are triggered when you release "v". This has consequences.

Assuming you only do this with "v", the following happens if you can type decently fast. You want to write "event", but the result is "eevnt". The letter "v" was typed when the key was released, while the following "e" was typed when the key was pressed. This leads to an incorrect sequence of letters.

It would be ideal if you could have both functions when a key is pressed. But that is not possible. Nevertheless, this problem can be solved. You have to reverse the whole system. All letters must be typed when the key is released, even if they have no second function. That way the timing is right. It works well, what you type appears on the screen with a slight delay. You quickly get used to this. But the letters are always in the right order.

This system is great. You can type very quickly and without errors or trigger a second function if you hold down a key for longer. All without modifiers!

However, this does not seem to work with KM. To be able to write normally, the trigger "is released" is required. But then "is long pressed" does not work. It could work with a multipress macro. But I do this with BTT.

Apart from that, unfortunately other problems arise, some in completely unexpected Situations. I am trying to solve them one by one. At the moment I only use this system in my writing program, where it works perfectly :slightly_smiling_face:

Applications like TextExpander that are more specific to this sort of problem might be helpful.

Set up a "shortcut" like thh and have it replaced by "there " works pretty well in my hands. You have to be sure that the designated shortcut like thh does not occur in normal English.

TextExpander also has helpful concepts like whitespace to further narrow down the abbreviation. For example, many words might actually end or contain ck making it an unworkable shortcut. However, you could specify "whitespaceck" as a shortcut for something like "chink " and it would work fine. If you started a word with the letters ck then it would immediate launch the replacement. English words do not start with the letters "ck".

IMO a library of such shortcuts is easier to manage in an application like "TextExpander" than the equivalent in KM.