How to Toggle WiFi On and Off with a Keyboard Shortcut on Mac

Download ArticleDownload Article

Do you find it annoying to have to navigate to the WiFi icon every time you want to turn off the WiFi on your Mac? Fortunately, there's an easier way. By setting up a keyboard shortcut, you can turn your Mac's WiFi on and off by pressing just one key!

Part 1
Part 1 of 2:

Creating the Action

Download Article
  1. How.com.vn English: Step 1 Open Terminal.
    Copy paste this in: networksetup -listnetworkserviceorder.
  2. How.com.vn English: Step 2 Remember the number that shows the WiFi.
    Then, you can close Terminal and open Automator.
    Advertisement
  3. How.com.vn English: Step 3 Choose a type for your document.
    Click on Quick Action and Choose.
  4. How.com.vn English: Step 4 Search for run shell script in the search bar on the left.
    Double click on it.
  5. How.com.vn English: Step 5 Make sure the top section is correct on the right:
    Workflow receives no input in any application.
  6. How.com.vn English: Step 6 Copy and paste...
    Copy and paste the following script into the section of “Run Shell Script,” substituting “X” with any number that you found the WiFi port to be earlier. The script is: networksetup -getairportpower enX | grep "On" && networksetup -setairportpower enX off || networksetup -setairportpower enX on.
  7. How.com.vn English: Step 7 Click on Run in the top right corner.
    See if your WiFi turns off. You might need to wait a few seconds. If it works, click on the X and save the action, and name it something obvious like “WiFi Toggle.” Then, proceed to the next section.
  8. Advertisement
Part 2
Part 2 of 2:

Creating the Keyboard Shortcut.

Download Article
  1. How.com.vn English: Step 1 Open System Preferences > Keyboard.
    At the top, click on Shortcuts.
  2. How.com.vn English: Step 2 Click on Services.
    Scroll to the very bottom until you find the action that you just created.
  3. How.com.vn English: Step 3 Click on the None to the right of the name.
    Then, click on Add Shortcut.
  4. How.com.vn English: Step 4 Type in your shortcut.
    You might use Ctrl+ Opt+ Cmd+W. Control Option Command W). Make sure the shortcut is not a common shortcut.
  5. How.com.vn English: Step 5 Test your shortcut.
    It should work!
  6. Advertisement


Community Q&A

Search
Add New Question
  • Question
    What OS system does this work on? It doesn't seem to be working on Mojave.
    How.com.vn English: Evan Huang
    Evan Huang
    Community Answer
    This should be working on Mojave. I tested it and it worked. Copy paste the code you entered into the section Run Shell Script.
Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
      Advertisement

      Tips

      Submit a Tip
      All tip submissions are carefully reviewed before being published
      Thanks for submitting a tip for review!

      About This Article

      How.com.vn is a “wiki,” similar to Wikipedia, which means that many of our articles are co-written by multiple authors. To create this article, volunteer authors worked to edit and improve it over time. This article has been viewed 54,189 times.
      How helpful is this?
      Co-authors: 7
      Updated: May 31, 2023
      Views: 54,189
      Categories: Computer Keyboards | Mac
      Thanks to all authors for creating a page that has been read 54,189 times.

      Is this article up to date?

      ⚠️ Disclaimer:

      Content from Wiki How English language website. Text is available under the Creative Commons Attribution-Share Alike License; additional terms may apply.
      Wiki How does not encourage the violation of any laws, and cannot be responsible for any violations of such laws, should you link to this domain, or use, reproduce, or republish the information contained herein.

      Notices:
      • - A few of these subjects are frequently censored by educational, governmental, corporate, parental and other filtering schemes.
      • - Some articles may contain names, images, artworks or descriptions of events that some cultures restrict access to
      • - Please note: Wiki How does not give you opinion about the law, or advice about medical. If you need specific advice (for example, medical, legal, financial or risk management), please seek a professional who is licensed or knowledgeable in that area.
      • - Readers should not judge the importance of topics based on their coverage on Wiki How, nor think a topic is important just because it is the subject of a Wiki article.

      Advertisement