Disabling stuck keys on broken hardware

A friend has a hardware problem with their laptop . a stuck key.

This handy piece of nix remaps it to reserved. This might be useful to anyone who trying to get broken keyboards going.

{ pkgs, config, lib, ... }:
{
  # Disable my right arrow key, since it is broken.
  systemd.services.keycode-swap = {
    enable = true;
    serviceConfig = {
      Type = "oneshot";
      RemainAfterExit = true;
    };
    wantedBy = [ "multi-user.target" ];
    script = ''
      ${pkgs.kbd}/bin/setkeycodes 106 0
    '';
  };
}

The Magic number 106 and 0 , can be referenced here…

have funnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn

As long as it’s just a single key and it’s not used often, this might work temporarily.

Though remember that most keyboards can’t send more than 2 or 3 pressed keys at the same time.

Some can at least increase that number for certain game relevant combinations.

The more sophisticated keyboards that can actually send an arbitrary number of keycodes at the same time are at the same time flexible enough to fix that problem on their qmk firmware.

Long story short: your friend should make sure to replace the keyboard (or the stuck switch) soon.

1 Like
Hosted by Flying Circus.