I am working on a site that displays images and forms from a database. Currently, I have links disguised as buttons that allows the user to switch to previous and next files.
$prev_key=$filenum.'_'.($fileindex-1);
$next_key=$filenum.'_'.($fileindex+1);
if(($fileindex-1)>=1)
echo '<br>';
echo ' <a href="view_file.php?k='.$prev_key.'" class="prevnext">Prev File</a>';
if(($fileindex+1)<=$totalfilect)
echo ' <a href="view_file.php?k='.$next_key.'" class="prevnext">Next File</a>';
This works well, but I also want the user to be able to switch files using the up (previous) and down (next) arrow keys. How could I either call the $prev_key
and $next_key
functions or have the key presses just activate the links with key presses?