Home » How To » How to Eject USB Using Keyboard Shortcut on Windows 11 & 10

How to Eject USB Using Keyboard Shortcut on Windows 11 & 10

To safely remove a plugged-in USB drive or flash drive, we typically use the “Eject Media” option from the system tray on the taskbar. While it only takes a couple of clicks, if you’re doing this frequently, it can get repetitive. In those cases, setting up a keyboard shortcut to eject the USB drive can save time.

The problem is that Windows doesn’t have a built-in keyboard shortcut. So, we’ll use USB Disk Ejector and AutoHotKey to create a custom keyboard shortcut for ejecting your flash drive. The best part is, you can assign any shortcut you prefer. So, without further ado, let’s get started and learn how to use a keyboard shortcut to safely eject a USB drive in Windows 11 and Windows 10.

Before You Start

  • Download the USB Disk Ejector from this page. We use this tool to eject the USB drive.
  • Download AutoHotKey from this page. We use this software to assign a keyboard shortcut for USB ejection. After downloading, double-click the installer file and follow the on-screen instructions to install AutoHotKey.

Keyboard Shortcut to Eject USB on Windows

  1. Extract the USB Disk Ejector zip file to a folder.
  2. Press the Start button.
  3. Search and open “Notepad“.
  4. Paste the following command in the Notepad.
    ; Press Ctrl + Alt + E to eject USB
    ^!E::
    {
      Run('C:\path\to\USB_Disk_Eject.exe /removeletter DriveLetter:')
    }
  5. Replace the dummy USB Disk Ejector path with the real path.
  6. Replace the dummy drive letter with the drive letter of the USB drive.
  7. Go to where you want to save the file and click the “File” > “Save as” option.
  8. Enter “USBEject.ahk” in the “File Name” field.
  9. Select “All Files” from the “File type” dropdown menu.
  10. Click the “Save” button.
  11. Close the Notepad window.
  12. Double-click the “USBEject.ahk” file.
  13. From now on, press the “Ctrl + Alt + E” shortcut to eject USB.

Detailed Steps (With Screenshots)

First, find the downloaded USB Disk Ejector zip file you downloaded earlier, right-click on it, and select the “Extract all” option. Next, click the “Extract” button to extract the ZIP file to the same folder as the source file.

extract usb disk extractor zip file

After extracting, we need to create the AutoHotKey script to assign a shortcut to eject the USB. To do that, press the Start button on your taskbar, search for “Notepad” and click the “Open” option.

open notepad using the start menu

In the Notepad window, paste the following code. Next, replace the dummy path with the actual path to the USB Disk Ejector exe file. After that, replace the dummy drive letter (DriveLetter) with the drive letter of the USB drive. For example, my USB drive letter is “G”.

Note: You can get the USB Disk Ejector file path by right-clicking on the file and selecting the “Copy as path” option.

; Press Ctrl + Alt + E to eject USB
^!E::
{
  Run('"C:\path\to\USB_Disk_Eject.exe" /removeletter DriveLetter:')
}
ahk script to eject usb with keyboard shortcut

After that, click the “File” > “Save as” option.

click file and then save as

Go to the folder where you want to save the script file, enter “USBEject.ahk” in the “File name” field, select “All files” from the “File type” dropdown menu, and click “Save“.

save ahk script

Close the Notepad window.

Now, go to the folder where you saved the “USBEject.ahk” script file and double-click it to run it.

run ahk script

As soon as you do that, the AutoHotKey script runs. You can see the script icon on the taskbar. As long as the script is running, you can press the “Ctrl + Alt + E” to eject the USB drive.

usb eject notification after pressing keyboard shortcut

To customize the keyboard shortcut, change the “^!E” part of the script. In this notation, “^” is for Ctrl, “!” is for Alt, “#” is the Windows key, and “+” is Shift. For example, if you want “Ctrl + Shift + E” as your shortcut, update it to “^+E”. You can find more about these key symbols and how to use them in scripts here.

Wrapping Up — Keyboard Shortcut to Eject USB

As you can see, while there is no built-in option, you can create your own customized keyboard shortcut to quickly eject the USB drive. Keep in mind that for the shortcut to work, the script file should be running in the background. To make sure it happens, you can either manually run the script or add the AutoHotKey script to startup.

If you have any questions or need help, comment below. I’ll be happy to assist.

Leave a Comment

Your email address will not be published. Required fields are marked *