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

Feature request: make actions like fork and switch react to keys being pressed without sending/inputting them, or a way to block their input #782

Closed
flamingjupiter opened this issue Feb 26, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@flamingjupiter
Copy link

Is your feature request related to a problem? Please describe.

I wanted a way to kanata do something if I have a key pressed/held, but without sending that key i.e. do x normally, but do y if kp2 (numpad key 2) is pressed, but never sending/inputting the kp2 key (so the number 2 won't be spammed).

I guess that would effectively sacrifice the key, at least on that hypothetical layer, but it's tradeoff that's worth it. And you could always type that key normally on another layer, if needed.

I guess a solution would be to remap, say, the kp2 key to a non-printable character, like f13-f24. But I would like to use other keys (printable keys) because I'm already using those non-printable characters for other functions. And they aren't enough e.g. I have a mmo mouse with 13 buttons (besides mleft mrgt mmid). The f13-f24 keys simply aren't enough to cover all of them (not even counting the other uses those non-printable keys are assigned already), hence the need to do it with printable keys as well.

Describe the solution you'd like.

An action to block the key, but still make it key press and key release recognizable to kanata e.g. for the fork, switch, fakekeys functions.

Describe alternatives you've considered.

Couldn't think of any alternatives.

Additional context

No response

@flamingjupiter flamingjupiter added the enhancement New feature or request label Feb 26, 2024
@jtroo
Copy link
Owner

jtroo commented Feb 26, 2024

Resolving this ticket might also satisfy the use case:
#393

@jtroo
Copy link
Owner

jtroo commented Feb 27, 2024

The implementation of operating on fake keys for switch/fork should be a mostly straightforward reimplementation of the mentioned actions, but instead of operating on active keycodes, the underlying action would operate on coordinate - and the parsing layer makes use of the appropriate fake key coordinates.

@jtroo
Copy link
Owner

jtroo commented Feb 27, 2024

Some of the relevant code in case someone wants to give it a shot:

https://github.com/jtroo/kanata/blob/main/keyberon/src/action/switch.rs

Switch(sw) => {

Fork(fcfg) => {

fn parse_switch(ac_params: &[SExpr], s: &ParsedState) -> Result<&'static KanataAction> {

fn parse_fork(ac_params: &[SExpr], s: &ParsedState) -> Result<&'static KanataAction> {

fn parse_fake_keys(exprs: &[&Vec<SExpr>], s: &mut ParsedState) -> Result<()> {

@jtroo
Copy link
Owner

jtroo commented Mar 13, 2024

This is now partially implemented in #809

@jtroo
Copy link
Owner

jtroo commented Mar 14, 2024

This should now be implemented, though without documentation yet.

Can follow the test example to see how it works for now

(deffakekeys vk1 XX)
(deffakekeys vk2 XX)

((input virtual vk1)) $var1 break
((input real lctl)) $var1 break
((input-history virtual vk2 1)) $var1 break
((input-history real lsft 8)) $var1 break

As a note the naming change from fake to virtual as in discussed in #790 is in progress.

@jtroo
Copy link
Owner

jtroo commented Mar 18, 2024

The functionality is now documented too

@jtroo jtroo closed this as completed Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants