Back to home clicking out

Hi,
 I would like add two features in the project one is back to home page on click out when i'm seeing the images on preview, the second one is navigate between the images with the keyboard arrows. But in the first one I don't find where put my function and my event listener :'(