Using karabiner to address the issue of double pressing

I have this problem (again) - pressing one key (b for me) sometimes makes it to be registered twice. https://discussions.apple.com/thread/7840547

Is there a way to use karabiner-elements to modify such that when a key is pressed twice within a short time the second key will not be registered? https://pqrs.org/osx/karabiner/complex_modifications/


For your special case I would suggest you use Karabiner Elements. and edit its ~/.config/karabiner/karabiner.json this way (added to/after "rules"):

EDIT / fail-safe version:
– Copy/paste the code below into TextEdit and "Save as..." WhateverNameYouLike.json
– Next manually move a copy to ~/.config/karabiner/assets/complex_modifications/
– Finally import from KE: tab "Complex Modifications", buttons [+ Add rule] & [+ Enable]

{ "title": "Keep solitary letter/key ''b'' from multiple press!",
  "rules": [
     { "description": "Keep 'b' from being pressed twice",
       "manipulators": [
        { "from": { "key_code": "b" },
          "parameters": {"basic.to_if_held_down_threshold_milliseconds": 10},
          "to_if_held_down":[
                 { "key_code": "b",
                   "repeat": false }],
          "type": "basic"
                }  
            ]
        }
    ]    
}

As you can see letter "b" is NOT re-mapped but in "to_if_held_down" kept from being repeated by "repeat": false; obviously letter 'b' may be substituted with any other failing letter.
(The threshold is defined to a minimal 1/100 second, so you won't notice any difference ...)

Please report if this code does for you what it's supposed to do.
[EDIT:] This solution works for the user in (ex-) trouble.
(I had to simulate the situation by testing in an app that does repeat keys if held down – but actually yours may be a non-solvable mechanical problem …)

Note:
This method, though, may not be advisable/applicable, if the holding-down of a key (e.g.: "a") in an app opens a small window above it offering (e.g.:) "ä" / "å" / "ậ" or similar choices – IF you need those special characters.
This behaviour would be prevented by "repeat": false.
But then:
You can activate "Show Keyboard & Character Viewers in menu bar" in System Preferences and get them from the menu bar...


A Python3 helper script to the above answer, which maps all the keys:

import json
import string
letters = list(string.ascii_lowercase)

for x in letters:
    output = {'title': f'Double Type {x}',
          'rules': [
             {
                'description': f'Keep `{x}` from a double keypress',
                'manipulators': [
                    {
                        'from': {'key_code': f'{x}'},
                        'parameters': {"basic.to_if_held_down_threshold_milliseconds": 10},
                        'to_if_held_down': [
                             {
                                'key_code': f'{x}',
                                'repeat': 'false'
                            }
                        ],
                        'type': 'basic'
                        }  
                ]
            } 
          ]
    }
    with open(f'doubletype_{x}.json', 'w')as outfile:
        json.dump(output, outfile)
        
# Copying files to directory
import glob
import shutil
from os.path import expanduser

home = expanduser("~")

print('Copying files...')
for file in glob.glob('doubletype_*'):
    shutil.copyfile(file, f'{home}/.config/karabiner/assets/complex_modifications/{file}')
print('Copying files complete!')

This will generate 26 files (one for each letter), and copy them to the appropriate directory.