Make NUI out of item - QBCORE

Hello, I was wondering if anyone knew how to make a item when clicked on into a NUI. I have been trying to make items useable and once clicked on it will provide a simple image then once you click esc it will close. If anyone could help it would be greatly appreciated, thanks!

Trigger event from your NUI script when you use an item.
Then you can close your window by esc e.g using js.

$(document).keydown(function (e) { 
  if(e.keyCode === 27 || e.key === "Escape") {
//     post close 
//
//     $.post(`https://${GetParentResourceName()}/close`, 
//     JSON.stringify({
//       toggle: toggle
//     })
  }
});

Now that goes in the server lua right because it is a trigger event? Also how would I connect that to the item and put that into the NUI so when I click on lets say a image it will show the image then do as you put on there once key 27 is pressed it closes.

Did you ever figure this out? I’ve been trying to figure out a way to do this with a photograph as an item and then have the image viewable