Skip to content

Ranges as KCAction keys #3

@eygengrau

Description

@eygengrau

Hi again! I thought I should keep this as a seperate issue.

I tried to use ranges as a key, which the readme implies (at least to me) should work. But the following example gives me an error "key not found" if I enter a digit.

#SingleInstance Force
#Include ./KeyChord.ahk
testChord := KeyChord(KCAction('1-9', () => MsgBox('digit'), True, 'Digit'))
KCManager.Execute(testChord, 1, 5)

I can make it work by changing line 939 from

FindTrue(key) => this.Transform((action) => ((action.Key == key) or (action.Key == RegExReplace(key, "(<|>)*", ""))) and action.IsTrue(), True)

to

FindTrue(key) => this.Transform((action) => ((KeyChord.MatchKey(action.Key, key)) or (KeyChord.MatchKey(action.Key, RegExReplace(key, "(<|>)*", "")))) and action.IsTrue(), True)

That being said, I don't know if that causes unwanted side effects. I also haven't tested it on other ranges.

As an aside: For my use case I need to know which key of the range was pressed. I can achieve that by applying the following changes:

; line 166
Execute(timeout, parent_key, input)
; line 178
this.Command.Call(input)
; line 1147
result := chord.Execute(timeout, parent_key ", " input, input)

The actions need then to be adjusted like that:

testChord := KeyChord(
	KCAction('1-9', (i) => MsgBox('digit: ' i), True, 'Digit'),
	KCAction('a-z', (*) => MsgBox('unused input'), True, 'Letter'),
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions