MacOS – Safari Javascript disables F4 key

macbook promacos

I have a strange problem with my new MacBook Pro running Sierra.
After visiting some web sites (such as stackexchange, gmail, and web.whatsapp.com), the F4 key stops to work in all applications. All other function keys continue working normally, as well as starting launchpad (which is also on the F4 key). It seems pressing the F4 key does not generate any key code anymore, according to Key Codes.

  • This happens both with the internal MacBook keyboard as well as the apple wireless keyboard.
  • Logging out and logging in again (or rebooting) fixes the F4 key, only quitting Safari does not fix it.
  • Disabling Javascript (via Safari preferences) leaves the F4 key enabled.
  • Other browsers (Chrome, Firefox) are not affected by this issue.
  • It is a completely fresh installation of Sierra and happens without installing any additional programs or modifying any settings. Tested with 10.12.2 and 10.12.3.

Did anyone notice the same issue?

Does anyone have an idea how to debug or prevent this issue?

An easy way to test if you have this issue is by:

  1. Log in.
  2. Start the terminal.
  3. Press Control-v and F4 in the terminal. It should print ^[OS.
  4. Start Safari, go to stackexchange.com.
  5. Repeat step 3, nothing gets printed on the terminal. Pressing Control-v and F3 still prints the correct code for F3, ^[OR.

Best Answer

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!

  1. Shutdown your MBP
  2. Switch on your MBP
  3. Immediately press and hold the CommandR keys until you see the Apple logo appear
  4. When you see the Utilities window appear, select Disk Utility and click on Continue
  5. Select your MBP drive from the sidebar on the left
  6. Click on the Erase button
  7. Click on the Format drop-down list and select Mac OS Extended (Journaled)
  8. Enter a name for your disk
  9. Click Erase
  10. When completed, Quit Disk Utility
  11. Select Reinstall macOS from the Utilities window (do not choose the Restore from Time Machine Backup option)
  12. Follow the instructions to reinstall macOS
  13. 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.
  14. When complete, test to see if your issue still persists
  15. 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.
  16. Now test to see if your issue is still gone
  17. 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.