mirror of
https://tt-rss.org/git/tt-rss.git
synced 2024-06-23 11:46:37 +02:00
keydown returns the "raw" key in event.which. Depending on the keyboard layout, this may not be what is wanted. For example, on a German keyboard, Shift+7 has to be pressed to get a slash. However, event.which will be 55, which corresponds to "7". In the keypress event, however, event.which will be 47, which corresponds to "/". Sadly, several important keys (such as escape and the arrow keys) do not trigger a keypress event. Therefore, they have to be handled using a keydown event. This change refactors the hotkey support to make use of keypress events whenever possible. This will make hotkeys work regardless of the user's keyboard layout. Escape and arrow keys are still handled via keydown events. There should be only one change in behavior: I could not make Ctrl+/ work and therefore rebound the help dialog to "?".
32 lines
571 B
PHP
32 lines
571 B
PHP
<?php
|
|
class Hotkeys_Noscroll extends Plugin {
|
|
private $host;
|
|
|
|
function about() {
|
|
return array(1.0,
|
|
"n/p hotkeys move between articles without scrolling",
|
|
"fox");
|
|
}
|
|
|
|
function init($host) {
|
|
$this->host = $host;
|
|
|
|
$host->add_hook($host::HOOK_HOTKEY_MAP, $this);
|
|
}
|
|
|
|
function hook_hotkey_map($hotkeys) {
|
|
|
|
$hotkeys["(40)|Down"] = "next_article_noscroll";
|
|
$hotkeys["(38)|Up"] = "prev_article_noscroll";
|
|
$hotkeys["n"] = "next_article_noscroll";
|
|
$hotkeys["p"] = "prev_article_noscroll";
|
|
|
|
return $hotkeys;
|
|
}
|
|
|
|
function api_version() {
|
|
return 2;
|
|
}
|
|
|
|
}
|