Change wait time for secondary key/ role?

When I use a secondary function for a key I sometimes miss keystrokes or trigger the second function although accidently. Can I increase the wait time till the second function is triggered? What is the default time now?

If you mean the regular (not smart macro) secondary role, then there is no wait time. If you press another key while holding a secondary-role key, secondary role activates. If not, primary role is activated when the key is released.

Thanks Karel, I think I did not understand it right then. With the time I meant the default “timeout”. It can not be 0. That would be the equivalent of, which basically means the first line (tapKey space) will never be used!?

resolveSecondary 0 0 1 3
tapKey space
break
holdLayer mod

The question is interesting in that sense how to possibly finetune the timeout, when one is not happy with the default secondary role timeout behavior.

Are we talking regular secondary roles (those available via Agent key popover GUI), or resolveSecondary?

If regular secondary roles, then there is no timeout, no timer, no waiting period. If press period of a secondary-role key overlaps with press period of next key, then secondary role is engaged.

If there is no (other) press at the time of release of the secondary role key, then a brief tap of the primary action is issued.

1 Like

I am talking about both ‘secondary roles’ and ‘resolveSecondary’. Basically I want to understand how I could replicate the ‘secondary role’ with ‘resolveSecondary’. Reason is that this knowledge can be helpful to find good timing parameters and/ or better understand when to use which of the two options.

Basically I want to understand how I could replicate the ‘secondary role’ with ‘resolveSecondary’.

I don’t think you can. They are different resolution strategies.

(Sorry for the confusion, indeed this needs to get refactored.)

IIUC, the built-in secondary role configurable though the UI is roughly equivalent to using ifInterrupted in a macro, e.g.:

ifInterrupted final holdLayer mouse
holdKey escape

Couldn’t you differentiate this using ifPlaytime ?

ifPrimary final tapKey space
ifPlaytime 300 final holdLayer mouse
tapKey space

This should only activate the mouse layer if you hold space for more than 300ms.

This should only activate the mouse layer if you hold space for more than 300ms.

I am not sure about that. I believe ifPrimary may exit sooner than 300ms in if there is a quick tap of another key…

And that’s exactly the intention, it would then fallthrough the ifPlaytime and just act as a primary tap on space, plus the next character, wouldn’t it?

Well, I am not sure what the intention is, so if you say so¯\(ツ)/¯.

Let’s see if rpnfan is happy with this :slightly_smiling_face:

This discussion certainly helped me improve my own UHK configuration.

I have my UHK just for a week now, so trying to figure out how things work and how to setup my keys to get into and out of layers best. So at the moment I am not satisfied but in the search and test phase. :slight_smile:

I tested this, but can not get the mouse layer to work at all with this macro. I tried to change holdLayer to toggleLayer, but that did not make a difference.

What I am trying could be very useful for many I think. A robust secondary role of a key, which does not easily trigger unwanted keys. This is a problem with the standard implantation which Agent offers. :frowning:

I want a Space-Mod-key. When tapped Space should trigger, when hold I want it to become mod. This is possible with secondary role, but does trigger wrong events when typing fast. For example mod-d is currently assigned to Alt-Tab. But when one types very quickly it can happen that ‘space’ is still held down when d is pressed, thus triggering an Alt-Tab while I just wanted to have the string " d" instead.

A solution should be simple. Only trigger the mod-layer, after a minimum hold-time. I read the docs now and tried a few macro options, but seem to be on the wrong way, because nothing works so far.

The macro must do:

  • tap space, but only when time is shorter than (for example) 300 ms
  • tap space also when another key is tapped, while space is still hold down (in 300 ms), so in that case output space plus the key which was then tapped, exit the macro then
  • only when the hold time is longer than 300 ms toggle to the mod-layer, do whatever is defined when a second key is tapped. Do nothing, when the (space-)key is released without another key tapped.
1 Like

OK, let’s try this again. I just did some more tests, and this works for me on a UHK60 v2:

resolveSecondary 1000 500 1 2
final tapKey space
final holdLayer mouse

To make it easier to test this, the macro uses long timeouts, but please adjust the numbers to your liking. I have assigned this macro to the left space key.

Secondary action: The key will need to be held down for more than 1000 ms (= 1 second) to activate the mouse layer.

Primary action: If you tap the key (press down and release again in less than 1000 ms) without any other key being pressed during this time), it will send Space.

Overlap 1: If you hold the key for less than 1000 ms and tap a second key briefly, and let go of the key within 500 ms (= half a second), it will send Space, and afterwards the second key.

Overlap 2: If you hold the key for less than 1000 ms, press a second key, let go of the first key, then let go of the second key, it will also send Space, and afterwards the second key.

Overlap 3: if you hold the key down and within less than 1000 ms tap a second key, but still hold down the key for a total time of more than 1000 ms, it will activate the mouse layer and ignore the second keystroke.

2 Likes

And if you want it more readable, then here’s a version with labels:

resolveSecondary 1000 500 primaryaction secondaryaction
primaryaction: final tapKey space
secondaryaction: final holdLayer mouse

Let us know how this works for you.

2 Likes

@rpnfan you may want to go through https://github.com/UltimateHackingKeyboard/firmware/issues/207

Also, have you tried the alphanumeric-friendly strategy with default settings?

ifSecondary final holdLayer mouse
holdKey space

(This triggers different resolution strategy than the secondary role which is available in Agents key popover.)

1 Like

Thanks a lot Maximilian and Karel. I am now testing Maximilian’s suggestion and this seems to be exactly what I was trying to achieve! A big thank you!! :smiley:

Karel’s suggestion also seems to work much more error tolerant in regards of overlapping keystrokes than the default secondary role version – although maybe not as failsafe like Max’ suggestion when one chooses a timeout which is “long enough”?

Out of curiosity I just looked up what the default repeat delay for a keystroke in Windows is. That is 500ms, with options for 250ms, 750ms and 1000ms as well. So for fast typists 250ms seems a good choice. I tested how long my keystrokes take and they are typically below 100ms, so 250ms seems like a fairly safe timeout value. At the moment I am testing with 300 for both timeout and safety margin delay. I do not think a different value for timeout and safety has any benefit as far as I can see now.

I started to read the linked page Karel suggested. I have the same issue that sometimes a space was “dropped” and not registered. That was only a problem when the secondary role (standard agent solution) was used.

I will use both Karel’s and Max’ suggestion in daily life and see how it works.

P.S.: My mis attempts where using ifPlayTime and other commando’s, but it seems I have not yet understood when and how to use the different available commands. :-o

P.S.S.: Is there a good reason not to implement “alphanumeric friendly strategy” as a default in Agent?

  • The trouble with the alphanumeric-friendly strategy is that it introduces delays, which may cause problems for some usecases. (E.g., gaming)

  • Another problem is that, as the github threads show, writing styles differ and as a consequence, different people require vastly differently configured resolution strategy.

But we do plan to refactor this so that it is be possible to configure which strategy to use by default.

P.S.S.: Is there a good reason not to implement “alphanumeric friendly strategy” as a default in Agent?

This is purely a firmware feature. Agent just edits the configuration.