mirror of
https://github.com/dscalzi/HeliosLauncher.git
synced 2024-12-22 11:42:14 -08:00
Added keyboard controls to the News UI.
On the landing view, the up arrow will open the News UI.
On the News UI, the left and right arrow keys will switch articles.
Thanks to aaronholtomcook/ElectronLauncher (26659f8c38
)
This commit is contained in:
parent
52d90276bf
commit
85331a7088
@ -986,6 +986,30 @@ function initNews(){
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add keyboard controls to the news UI. Left and right arrows toggle
|
||||||
|
* between articles. If you are on the landing page, the up arrow will
|
||||||
|
* open the news UI.
|
||||||
|
*/
|
||||||
|
document.addEventListener('keydown', (e) => {
|
||||||
|
if(newsActive){
|
||||||
|
if(e.key === 'ArrowRight' || e.key === 'ArrowLeft'){
|
||||||
|
document.getElementById(e.key === 'ArrowRight' ? 'newsNavigateRight' : 'newsNavigateLeft').click()
|
||||||
|
}
|
||||||
|
// Interferes with scrolling an article using the down arrow.
|
||||||
|
// Not sure of a straight forward solution at this point.
|
||||||
|
// if(e.key === 'ArrowDown'){
|
||||||
|
// document.getElementById('newsButton').click()
|
||||||
|
// }
|
||||||
|
} else {
|
||||||
|
if(getCurrentView() === VIEWS.landing){
|
||||||
|
if(e.key === 'ArrowUp'){
|
||||||
|
document.getElementById('newsButton').click()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display a news article on the UI.
|
* Display a news article on the UI.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user