How to lock and unlock a MacBook keyboard

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.


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. Junk files include temporary files that were never removed, cache files, leftover files from applications that are no longer on your Mac, and language files for languages you don’t use. Getting rid of all those files manually would take a lot of time and effort. And there is no way to identify and remove malicious files without a specialist tool. CleanMyMac X’s Smart Scan module does both of those things by scanning your Mac for junk and malware. It also looks for opportunities to optimize the performance of your Mac by looking for background extensions you may not use. Once it’s scanned your Mac, it will tell you what it’s found, and you can decide whether to delete everything with a click or review the results and choose what to remove. You can download CleanMyMac X for free here and try it for yourself.

CleanMyMac X - Smart Scan complete

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 in macOS Sonoma, 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-L to lock the screen.

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 - Lock Screen

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.

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.

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 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.

Laptop with CleanMyMac
CleanMyMac X

Your Mac. As good as new.