Si pruebas algo así
    
Código HTML:
Ver original- <script language="javascript"> 
- function PulsarTecla(event) 
- { 
-     tecla = event.keyCode; 
-   
-     if(tecla==37) 
-     { 
-         //foto anterior 
-        alert("37") 
-     } 
-      
-     if(tecla==39) 
-     { 
-         //foto siguiente 
-        alert("39") 
-     } 
- } 
-   
- window.onkeydown=PulsarTecla;