2013-03-12 07:35:41 +00:00
|
|
|
<?php
|
|
|
|
class GoogleReaderKeys extends Plugin {
|
|
|
|
private $host;
|
|
|
|
|
|
|
|
function about() {
|
|
|
|
return array(1.0,
|
2013-03-16 11:06:59 +00:00
|
|
|
"Keyboard hotkeys emulate Google Reader",
|
2013-03-12 07:35:41 +00:00
|
|
|
"markwaters");
|
|
|
|
}
|
|
|
|
|
|
|
|
function init($host) {
|
|
|
|
$this->host = $host;
|
|
|
|
|
|
|
|
$host->add_hook($host::HOOK_HOTKEY_MAP, $this);
|
|
|
|
}
|
|
|
|
|
|
|
|
function hook_hotkey_map($hotkeys) {
|
|
|
|
|
2013-03-16 11:06:59 +00:00
|
|
|
$hotkeys["j"] = "next_article_noscroll";
|
|
|
|
$hotkeys["k"] = "prev_article_noscroll";
|
2013-03-18 16:59:48 +00:00
|
|
|
$hotkeys["*n"] = "next_feed";
|
|
|
|
$hotkeys["*p"] = "prev_feed";
|
2013-03-16 11:06:59 +00:00
|
|
|
$hotkeys["v"] = "open_in_new_window";
|
|
|
|
$hotkeys["r"] = "feed_refresh";
|
2013-03-22 12:40:39 +00:00
|
|
|
$hotkeys["m"] = "toggle_unread";
|
2013-05-19 08:09:47 +00:00
|
|
|
$hotkeys["o"] = "toggle_expand";
|
Refactor hotkeys to use keypress instead of keydown
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 "?".
2019-03-11 10:29:10 +00:00
|
|
|
$hotkeys["\r|Enter"] = "toggle_expand";
|
|
|
|
$hotkeys["?"] = "help_dialog";
|
|
|
|
$hotkeys[" |Space"] = "next_article";
|
|
|
|
$hotkeys["(38)|Up"] = "article_scroll_up";
|
|
|
|
$hotkeys["(40)|Down"] = "article_scroll_down";
|
2013-03-12 07:35:41 +00:00
|
|
|
|
|
|
|
return $hotkeys;
|
2013-04-19 13:31:56 +00:00
|
|
|
}
|
2013-03-12 07:35:41 +00:00
|
|
|
|
2013-04-19 13:31:56 +00:00
|
|
|
function api_version() {
|
|
|
|
return 2;
|
2013-03-12 07:35:41 +00:00
|
|
|
}
|
2013-04-19 13:31:56 +00:00
|
|
|
|
Refactor hotkeys to use keypress instead of keydown
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 "?".
2019-03-11 10:29:10 +00:00
|
|
|
}
|