Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implemented an alt-repeat key #1392

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Nuclear-Squid
Copy link

@Nuclear-Squid Nuclear-Squid commented Nov 29, 2024

Describe your changes. Use imperative present tense.

Implemented an alt-repeat key. It functions the same as the standard repeat key, but takes in a list of pairs of keycodes to give substitutions. For instance, you can repeat keys as usual, but send e instead of d when repeating the d key.

A possible use-case for such a feature is to implement the "magic key" from Magic-Sturdy

Disclaimer : I am not a native English speaker, I am sorry if there are typos in the docs ^^'

Checklist

  • Add documentation to docs/config.adoc
    • Yes or N/A
  • Add example and basic docs to cfg_samples/kanata.kbd
    • Yes or N/A
  • Update error messages
    • Yes or N/A
  • Added tests, or did manual testing
    • Yes

@Nuclear-Squid Nuclear-Squid changed the title Alt repeat feat: implemented an alt-repeat key Nov 29, 2024
@Nuclear-Squid
Copy link
Author

This implementation only allows simple KeyCode -> KeyCode substitutions, which is still pretty limited. It’s not possible to repeat macros for instance (or alt-repeat a symbol with a macro), and rpt doesn’t seem to work with sequences (a sequence gg isn’t detected if you type it as g rpt). I’d like to help make that system more flexible, would you be interested in that ?

@jtroo
Copy link
Owner

jtroo commented Nov 29, 2024

Thanks for the contribution! Could you comment on the advantages of this action over switch?

https://jtroo.github.io/config.html#switch

@Nuclear-Squid
Copy link
Author

I added a small section at the end of the alt-repeat and switch’s key-history to reference each other. Is that good ?

@jtroo
Copy link
Owner

jtroo commented Dec 2, 2024

I added a small section at the end of the alt-repeat and switch’s key-history to reference each other. Is that good ?

It's more like - if the end goal is to implement magic sturdy, this PR could instead be a "tutorial" style document of using switch to implement magic sturdy.

To minimize code bloat and maintenance burden, it is desirable to have fewer ways to solve a problem. To add more flavour and context, Kanata does have different ways to do things over time as it has grown, though each added item has been written to solve a previously unsolved use case. For example; there are 3 different chording solutions:

  • the first implementation, a "within layer processing" action chord system
  • the second implementation, a "pre-layer processing" chord system inspired by ZMK, solving some issues with the first implementation
  • the third implementation, a "post-layer processing" chord system inspired more by zippychord/plover, enabling new use cases not possible (or very difficult to do) in the first and second implementations

There were strong reasons why the multiple chording solutions all exist.

Then there is switch and fork.

The fork action was implemented first and is the simpler variant. The switch action came later and is the more capable, implementing all use cases of fork and more. Already having the switch action, what problem does alt-repeat solve that is not already solved by using switch, where the base case is () rpt break?


(a sequence gg isn’t detected if you type it as g rpt).

Yea the sequences code paths aren't triggered by rpt today unfortunately. I don't make use of rpt or rpt-any myself so I don't have any motivation to fix it 😅. A workaround today would be listing every alphabet character in a switch case with history and outputting the appropriate character.

@jtroo jtroo added the gauging interest Looking for additional discussion and viewpoints label Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gauging interest Looking for additional discussion and viewpoints
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants