Consider the following hypothetical situation:
On a Macbook, A hacker can view the screen of your machine (and may have a keylogger installed).
It is impossible to remove them even by reinstalling the OS because the firmware of the machine has a deep rootkit installed.
Assuming, however, that the Bluetooth module of the machine is not hacked to transmit data, closing off network connections could be of some remedy to the situation.
However, you cannot set a new wireless router password without typing in that password, which will be hidden from the screen capture, but is then not copy/pastable (into the laptops's WiFi password settings for the router), because it is a hidden type form entry unless you elect to show the characters.
Putting aside the key logging argument for a moment, one could consider typing a completely random password into the router's hidden form for a new WPA2 key, which would (unless the router has also been rooted or modified) make access very difficult–closer to impossible, assuming a brute force attack on the router.
How could you then copy the same random password (which you yourself do not know) into the OS's WiFi settings? It's easy to change a password form to a text form, but then the purpose is defeated as the characters are displayed on the screen.
Is there any other option available, such as a wireless router with two-factor authentication, or another method of avoiding using a single password for WPA2?