gizak / termui

Golang terminal dashboard
MIT License
13.11k stars 786 forks source link

handler for "/sys/kbd/<" key is activated by other keys such as space #161

Closed mischief closed 5 years ago

mischief commented 7 years ago

the following code will produce this message when space is pressed:

    termui.Handle("/sys/kbd/<", func(e termui.Event) {
        fmt.Printf("%#v\n", e)
    })
termui.Event{Type:"keyboard", Path:"/sys/kbd/<space>", From:"termbox", To:"", Data:termui.EvtKbd{KeyStr:"<space>"}, Time:1501151628}

this is certainly unexpected behavior.

cklein commented 6 years ago

This is because isPathMatch only compares the len(pattern) first bytes, given pattern "/sys/kbd/<" and path "/sys/kbd/<space>", this yields true. A naïve patch breaks the unittests, I'm not sure yet if any code relies on this behaviour.

mischief commented 6 years ago

yes, it does just compare the bytes. however the current implementation seems to preclude the binding of the "<" key, which is an undesirable limitation of a library like this. also using these weird /sys strings is silly.

cjbassi commented 5 years ago

Keypress handling has been reworked and this should be working now. :+1: