Key navigation

Key navigation

sanyikasanyika Posts: 2Questions: 0Answers: 0
edited August 2009 in Plug-ins
I added som feature to the script....im not a professional with js so it can be more simple as this...
i added to jquery.dataTables.js some extra lines starting line 264...
[code]/* added left key function */
$().keypress(function (e) {
if (e.keyCode == 37) {
oSettings._iDisplayStart -= oSettings._iDisplayLength;

/* Correct for underrun */
if ( oSettings._iDisplayStart < 0 )
{
oSettings._iDisplayStart = 0;
}

fnCallbackDraw( oSettings );
}
});
/* added right key function */
$().keypress(function (e) {
if (e.keyCode == 39) {
/* Make sure we are not over running the display array */
if ( oSettings._iDisplayStart + oSettings._iDisplayLength < oSettings.fnRecordsDisplay() )
{
oSettings._iDisplayStart += oSettings._iDisplayLength;
}

fnCallbackDraw( oSettings );
}
});[/code]
its a feature that enable listing with left or right arrow on keyboard... i hope it can be usefull for somebody...

Replies

  • allanallan Posts: 63,573Questions: 1Answers: 10,483 Site admin
    Hi sanyika,

    Good one! Thanks for posting that. I've done something a bit similar for a paging plugin function ( http://datatables.net/plug-ins/pagination ) - but you need to be focused on the input box in mine, rather than the global handler you have.

    Thanks for sharing!

    Allan
This discussion has been closed.