Use Unsupported Hotkeys in KeePass

08-03-2020 - 1 minute, 38 seconds - IT

For years I have used the "Open Calculator"-button on my keyboard as a hotkey to open KeePass. When I set up my new laptop, I wanted to configure KeePass to use my hotkey again – but it didn't work anymore.

The Problem

Even though I am not completely sure, I think the problem lays within an change on how keepass handles hotkeys.

The last time I configured KeePass, I simply went to Tools > Options > Integration and selected the "Show KeePass"-entry and pressed my "Open Calculator" button. And it worked. This time however, nothing happened when I pressed the supposed Hotkey Button. Most other buttons and combinations (for example: shift+F1) worked. But I wanted my Calculator-Hotkey.

The Solution

Step 1: Find out where KeePass stores its configuration file:

%APPDATA%\KeePass\KeePass.config.xml

Step 2: Be lucky, then find the correct KeePass hotkey setting

Luckily the settings are saved in an human readable form – XML. The XML-element we are looking for is named "HotKeyShowWindow". And it is an integer.

Step 3: Set the correct value for the desired hotkey

Knowing that KeePass is written in C# (you can download the source code from their webpage), I figured the integer could be an enum. So I looked up .NET keycodes on MSDN and found this: System.Windows.Forms.Keys

That enum does not feature an key for "Open Calculator", but for "LaunchApplication1" (182) and "LaunchApplication2" (183). i tried both and found the the "Open Calculator" button on my Keyboard is really the "LaunchApplication2"-Button.

Conclusion

Knowing how and where KeePass stores its configuration and how the selected hotkeys are stored makes it possible to use any Key you wantend, even if KeePass doesn't support it. You can even use any combination – the "Keys"-enum is marked with the "Flag" attribute, so you can simply add two values from the keys-enum to select an combination.

Here are the important parts of the resulting configuration file:

<?xml version="1.0" encoding="utf-8"?>
<Configuration xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Integration>   
        <HotKeyShowWindow>183</HotKeyShowWindow>
    </Integration>
</Configuration>

Next Post Previous Post