To begin with, this isn't about keeping users out of page source, as in this seven-year-old question. It's about keeping browser definitions of F1-F12 (both shifted and unshifted) from interfering with a browser-based terminal emulation.
Clearly, it can be done, because the IceCap 5250 emulator/screenscraper (demo here; if a sign-on screen is presented, use "demo" for both user and password) does it, and even prevents Chrome from acting on F12, but it's evidently not easy, because the "hotkeys" JavaScript library fails to keep Firefox from responding to F7 with some dialog about "caret browsing," and fails to keep Chrome from throwing up the Developer Tools sidebar in response to F12.
Can anybody here shed any light on this?