Hi all
is there an addon to manage keydown presses, that is to say, when I press keyboard arrow to right I go to the next sbling page, when I press keyboard arrow to left I go to the previous sbling page?
thanks in advance
sareide
Keydownmanagement
Keydownmanagement
Last edited by cmb on Sun Jul 06, 2014 9:15 pm, edited 1 time in total.
Reason: moved from "General Discussions" to "General Support" forum
Reason: moved from "General Discussions" to "General Support" forum
Re: Keydownmanagement
Hi sareide,
no, there is no such add-on. And it seems to me for this kind of functionality a CMSimple plugin is not the right solution[1]. Consider that you actually want to change the behavior of the browser; something that might be done via a bookmarklet, and might better left for the individual user to install.
It might be that some browsers already allow such navigation between pages, but they would probably need respective rel="next" and rel="prev" attributes, but these are not yet available in CMSimple(_XH). That is, however, planned for CMSimple_XH 1.6.3.
[1] It would be possible to do this with JavaScript, but that would be very annoying for some users (the arrow keys might be used for scrolling), and it might break other functionality of the website.
Christoph
no, there is no such add-on. And it seems to me for this kind of functionality a CMSimple plugin is not the right solution[1]. Consider that you actually want to change the behavior of the browser; something that might be done via a bookmarklet, and might better left for the individual user to install.
It might be that some browsers already allow such navigation between pages, but they would probably need respective rel="next" and rel="prev" attributes, but these are not yet available in CMSimple(_XH). That is, however, planned for CMSimple_XH 1.6.3.
[1] It would be possible to do this with JavaScript, but that would be very annoying for some users (the arrow keys might be used for scrolling), and it might break other functionality of the website.
Christoph
Christoph M. Becker – Plugins for CMSimple_XH
Re: Keydownmanagement
Hi
I'd like only two handlers to manage page left and page right. Consider that this feature is present in lightbox galleries, and It would be useful (with the add of a button toggle on the interface to set keyboard navigation on and off). or up and down for a child page.
I'm going to think a solution.....
bye
sareide
I'd like only two handlers to manage page left and page right. Consider that this feature is present in lightbox galleries, and It would be useful (with the add of a button toggle on the interface to set keyboard navigation on and off). or up and down for a child page.
I'm going to think a solution.....
bye
sareide
Re: Keydownmanagement
Okay, a simple solution for modern browsers only (IE >= 9, as well as current version of Chrome, Firefox etc.) All changes go to template.htm. At first you have to wrap containers with certain ID around the previous and next page links that are generated by CMSimple_XH:
Then add just before the closing </body> tag:
If a user holds down the left or right arrow for a while, the navigation repeats--that may be desireable or not. If not change "keydown" in the 4th line to "keyup".
Code: Select all
<div id="previous_page"><?php echo previouspage();?></div>
<div id="next_page"><?php echo nextpage();?></div>
Code: Select all
<script type="text/javascript">/* <![CDATA[ */
if (typeof document.addEventListener !== "undefined" &&
typeof document.querySelector !== "undefined") {
document.addEventListener("keydown", function (event) {
var a;
switch (event.keyCode) {
case 37: // left
a = document.querySelector("#previous_page a");
if (a) {
location.href = a.href;
}
break;
case 39: // right
a = document.querySelector("#next_page a");
if (a) {
location.href = a.href;
}
break;
}
});
}
/* ]]> */</script>
</body><!-- this line should be already there -->
Christoph M. Becker – Plugins for CMSimple_XH