diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e3f121..169d1d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added - Tab now also enters link selecting mode, like Enter (#48) +- Number keys can be pressed to navigate to links 1 through 10 (#47) ### Fixed - You can't change link selection while the page is loading diff --git a/display/display.go b/display/display.go index db5c1d5..3af09c4 100644 --- a/display/display.go +++ b/display/display.go @@ -317,6 +317,19 @@ func Init() { tabs[curTab].pageDown() return nil } + + // Number key: 1-9, 0 + i, err := strconv.Atoi(string(event.Rune())) + if err == nil { + if i == 0 { + i = 10 // 0 key is for link 10 + } + if i <= len(tabs[curTab].page.Links) && i > 0 { + // It's a valid link number + followLink(tabs[curTab], tabs[curTab].page.Url, tabs[curTab].page.Links[i-1]) + return nil + } + } } } // All the keys and operations that can work while a tab IS loading