Safari Javascript disables F4 key
Based on the info you've provided during our comments history, and the fact I couldn't replicate this issue on five separate computers, including three 2016 MacBook Pros running macOS Sierra 10.12.3, the only solution I have is to try a full reinstallation / test / update process.

IMPORTANT - Ensure you have a full backup before proceeding with these steps!


Shutdown your MBP
Switch on your MBP
Immediately press and hold the CommandR keys until you see the Apple logo appear
When you see the Utilities window appear, select Disk Utility and click on Continue
Select your MBP drive from the sidebar on the left
Click on the Erase button
Click on the Format drop-down list and select Mac OS Extended (Journaled)
Enter a name for your disk
Click Erase
When completed, Quit Disk Utility
Select Reinstall macOS from the Utilities window (do not choose the Restore from Time Machine Backup option)
Follow the instructions to reinstall macOS
When installation is complete and you have rebooted, follow the prompts to setup your MBP. However, do not choose to copy files or migrate any data from your backups. Instead, set the MBP up as a totally new computer.
When complete, test to see if your issue still persists
Assuming your issue is now resolved, use the Mac App Store to update macOS, Safari, etc. However, do not copy any of your backed up files yet.
Now test to see if your issue is still gone
If all is good, then copy your backed up data to your MBP again. You can do this by using Migration Assistant (located within the Utilities folder within your Applications folder).


NOTE - If your issue still persists at Step 14 (when you first test for it again) then go through the entire process again. However, this time at Step 3 hold the CommandOptionR keys instead so that you start up from Internet Recovery. This will take longer to do, but eliminates the possibilty of some random problem with the local Recovery partition.