How is this detected in js, if possible?

Is there a dev tools open event or does it detect f keys and right click events?

One of the ways this is detected is by window resizing. You can see an example npm package that can detect devtools here: https://github.com/sindresorhus/devtools-detect