Windows – Keys get stuck – bug in keyboard drivers

usb-keyboardwindows

I work as a programmer, and write pretty fast (not super fast though). In my work Dell laptop I often run across two bugs, which I suspect has to do with some underlying Windows keyboard driver ("underlying", since the bugs occur on a totally different brand of keyboard as well). It is not a physical property of the keyboard, I've tried replacing the keyboard itself. Both USB keyboard, btw.

These are the strange problems:

  • The Ctrl key hangs when I type fast – but it does not hang not physically – the "release key code" never reaches the operating system, it seems like. This happens frequently, say every 20 to 120 seconds when I'm in the zone. The way to resolve it is 1) to realize that the control key is considered pressed by the system and 2) press and release the right Ctrl key. The left Ctrl key doesn't fix the bug (I know they send different scan codes).

  • The Shift key "hangs" in the same way, but there is no way to get it unlocked by pressing and releasing the shift key, there seems to be an internal counter which hangs. This happens perhaps every 10 to 20 days. To resolve I 1) have to realize the Shift key is in a pressed state (it is impossible to work with the Shift key pressed, simply selecting another file in Explorer.exe becomes impossible, not to mention trying to write code in Eclipse) and to fix it I 2) run a script I wrote for AutoHotkey, which sends {SHIFT UP} to the system. Before I wrote the script, I had to reboot the computer…

I'm getting annoyed at this. What causes this and how can I solve those problems?

Edit: here's my AHK file:

RShift::LShift

^!+r::
  ; Show a black "splash" to reveal script reloading.
  Run %windir%\system32\cmd.exe /c
  Reload
return

^!+e::
  Edit
return

; Send shift-up.
#^!+s::
  ; Send shift-up to "fix" my office laptop bug.
  SendInput {Shift Up}
return

; -------------------------

!+a::
  Run C:\Program Files\Notepad++\notepad++.exe
return

^!+a::
  Run %windir%\system32\notepad.exe
return

^!+d::
  Run %programfiles%\git\bin\bash.exe, c:\RnD\PD\trunk
return

RunExplorer(root, startTitle, subpath, endTitle, filename)
{
  SetTitleMatchMode, 3
  IfWinExist, %endTitle%
  {
    WinActivate,%endTitle%
    return
  }
  else
  {
    var = /e,
    if (root != "")
    {
      var = /e,/root,%root%
    }
    Run "%windir%\explorer.exe" %var%
    WinWait,%startTitle%,,4
  }
  if (ErrorLevel == 0)
  {
    #WinActivateForce
    WinActivate,%startTitle%
    WinWaitActive,%startTitle%,,10
    if (subpath != "")
    {
      SendInput {LAlt Down}d{LAlt Up}{End}%subpath%{ENTER}{Tab}{Tab}
    }
    SendInput {Tab}%filename%
  }
}

;Opens project home folder.
#e::
  RunExplorer("C:\RnD", "RnD", "\protustom\trunk\implementation\Protom", "Protom", "ProtomDC")
return

;Opens My docs folder.
#m::
  RunExplorer("H:\", "V0c1573 on 'Vcn.ds.volvo.net\It-got\Home07' (H:)", "My Documents", "My Documents", "Auto")
return

;Opens program files
#h::
  RunExplorer("C:\", "Local Disk (C:)", "Program Files", "Program Files", "7")
return

#k::
  Run %windir%\system32\Control.exe
return

#c::
  Run calc.exe
return

#r::
  Run regedit.exe
return

; Stores a screen shot as tmp.png on the desktop.
; Take screenshot manually before running this.
#q::
  Run c:\WINDOWS\system32\mspaint.exe
  WinWaitActive, namnlös - Paint,,15
  if (ErrorLevel == 0)
  {
    Send ^v ; Paste screenshot.
    Send !am ; Save as.
    Send +{Tab}+{Tab}{Down}{ENTER}{Tab}{Tab} ; Save to desktop folder.
    Send tmp{Tab}{Down}{End}{ENTER}{ENTER} ; Write tmp.png.
    WinWaitActive, Spara som,,2
    if (ErrorLevel == 0)
    {
      Sleep, 100 ; Wait a bit for dialog to load.
      Send {Left}{Enter} ; Overwrite previous file.
    }
    Send !{F4} ; Close paint.
  }
return


; Shift+CapsLock turns on/off CapsLock.
;Capslock::Ctrl
;+Capslock::Capslock

Best Answer

  • Ctrl key:

    I assume that the line

    Capslock::Ctrl
    

    was not commented out when you had issues with the Ctrl key.

    Different keyboards and their drivers behave differently. Some won't register when CapsLock is released, since it usually does nothing.

    On my two keyboards, pressing and releasing CapsLock sends {LCtrlDown} on one and {RCtrlDown} on the other, but never {CtrlUp}. Pressing and releasing the respective Ctrl (but not the opposite one) fixes this.

    Besides commenting the line out, I can't think of solution for this.

  • Shift key:

    I managed to reproduce the behavior you explained once, but I don't know how I did it.

    However, I assume that the line

    RShift::LShift
    

    is the culprit.

    I can't explain how a {RShiftDown} might get send with the right Shift key remapped, but it certainly explains why pressing neither Shift key fixes this, since releasing the right Shift key will send {LShiftUp}.

    There might be a solution for this other than commenting the line out, but I'm not quite sure what you want to achieve with it.

Related Question