Monitor keypresses without focus?

Hi all,
I'm new to Linux, been at it a couple weeks. I have written a script that basically acts as a watchdog to ping a server on a set interval, make sure chromium-browser is running, and a couple other things (it displays data via web browser). I'd like to make it stop the script when I hit Esc. I have figured out how to do that except for when chrome is in the foreground. Is there any way I can get around this with scripting? Any help appreciated!

Oh, using Fedora 25, Xwayland disabled(using Xorg), if that matters (my understanding of the various components in windowing is still murky)

A shell script has little to no control of where it receives input from unless you're going to try opening up raw keyboard devices yourself. And then you'll end up having to translate the raw keycodes.

Also, probably should have stated the script itself starts chromium-browser

---------- Post updated at 02:57 PM ---------- Previous update was at 02:56 PM ----------

I was afraid of that. I was hoping there was some way thru X that I could redirect input or something similar. I need absolutely no interaction on the chromium-browser window itself, it's view-only.

To add to Corona688's reply...

I don't know the particulars for Fedora but Ubuntu's events sit in /dev/input/ as event6 in my case.

It will produce a BINARY _string_ that you will have to decode to get the required character(s).

This is a simple command that will monitor, (using MY /dev/input/event6 ):-

sudo cat /dev/input/event6

Note the "sudo" because you might need elevated access to read the device.

EDIT:
You could try xinput list keyboard it might just work...

Thanks, I'll see where I can get with that. Hopefully I will get to poke around and try it today.