how to handle left and right actions

How in add-on I can handle keyboard events when user press Left or Right?
I’m using:

PHP Code:
xbmc.executebuiltin('ShowPicture('+url+')'

to display image and like to go next or previous when user pressing left or right