There are a number of situations where you may want to lock the keyboard on your Mac. For example, you may step away from your Mac for a few minutes and want to make sure that no one accesses anything on it while you’re gone. Or you may want to clean the keyboard and ensure that you don’t accidentally input anything to an application or website while you do it. In this article, we’ll show you how to lock keyboard on Mac and unlock it again.

Why lock the keyboard on Mac?

The most common reason is to prevent accidental input while you’re cleaning the keyboard or moving it from one place to another. But you may also want to prevent other people from using it while you are away from your desk.

How to lock the keyboard on Mac

Sadly, there is no way to use a keyboard lock shortcut to lock and unlock the keys on your Mac’s keyboard. Nor is there a dedicated keyboard lock button. Some third-party keyboards do have lock keys, and these may work, in conjunction with the keyboard’s driver software, to lock the keyboard. However, these shouldn’t be confused with keys for scroll lock, number padlock, or swapping between function and media keys, which can also have padlocks on them. You can’t lock the keyboard from Terminal or System Settings — which is probably just as well, how to unlock a MacBook keyboard from Terminal?

So, if you can’t easily lock and unlock the keyboard, how else can you make sure that you or someone else isn’t able to, accidentally or otherwise, input anything from it? Well, there are a number of options.

Tip

It’s not just your keyboard that should be kept clean. Your Mac’s startup disk should also be cleaned up from time to time to stop it from becoming filled with junk files and remove any malicious files that you may have downloaded. The easiest way to do both is to run CleanMyMac’s Smart Care scan. It also looks for opportunities to optimize the performance of your Mac and lets you delete duplicate downloads and install vital app updates. You can test CleanMyMac for 7 days — get your free trial here.

CleanMyMac’s Smart Scan module

Lock Screen

The simplest solution is to lock the screen on your Mac. When you do that, it will display the lock screen with a text box for your password. And from macOS Sonoma onwards, you get the bonus of a large clock display, like the iOS lock screen.

  1. Click the Apple menu and choose Lock Screen; or
  2. Use the keyboard command Control-Command-Q to lock the screen.
How to lock screen on Mac

To unlock the screen again, just type in your password, use Touch ID, or authenticate with your Apple Watch.

If you have multiple user accounts on your Mac, you can also click on the accounts icon in the menu bar if it’s visible or in Control Center and choose Login Window. This will return you to the login window, where you will have to type your username and password to unlock, or choose from the list of users and type in your password, depending on how it’s configured in System Settings > Lock Screen.

System Preferences - macOS Lock Screen settings showing display timeout, password and login window preferences

Log Out

Another way to lock your Mac is to log out completely. This is less convenient than using Lock Screen because, as well as locking the screen, it quits any open applications and, therefore, closes documents. It also means you will have to log back in again, which is slower than unlocking the screen because it reloads login items and launch agents. And you will have to reopen applications and documents when you log back in.

  1. Click the Apple menu and choose Log Out; or
  2. Press Command-Shift-Q.
How to log out of account on Mac

Shut the lid

If your Mac is a MacBook, MacBook Air, or MacBook Pro, shutting the lid will put it to sleep and lock the screen. When you open the lid, you will need to unlock it with your password, Touch ID, or Apple Watch.

Set up a hot corner

Did you know that Apple has a built-in feature that allows you to use the corners of your touchbar to perform specific actions? It is called hot corners, and you can set it up to lock your screen.

Here's how to set up hot corners on MacBook: 

  1. Go to System Settings > Desktop and Dock.
  2. Click Hot Corners (you might need to scroll down).
  3. Choose a corner and select Lock Screen from the menu.
  4. Click Done.
How to set up hot corners on MacBook

Switch the keyboard off

Most Bluetooth keyboards have an off switch to save battery power or allow you to change batteries. So, if you need to clean the keyboard or want to stop other people using it, switch it off. 

Open a Text Edit document

OK, so this is cheating. But if you want to lock your keyboard without locking the screen so that you can clean it and don’t want to type characters or execute commands in an application or website, you could open a new document in Text Edit and keep it active. That way, if you accidentally press any keys while you’re cleaning, they will just be typed into Text Edit.

Use a third-party tool

There are some apps that allow you to lock the keyboard using a shortcut or a switch in the user interface. For example, OneMenu is a menubar tool that has a ‘keyboard cleaning’ mode that’s activated by a switch. 

So, there’s no way to lock and unlock the keyboard on a Mac. But you can achieve the same result in lots of different ways, including switching to the lock screen. Choose the method above that works best for you.