Slow keyboard response

I use Alt+Tab to switch between windows. But sometimes it takes about 20 seconds to respond which is extremely slow. I’ve noticed that /usr/lib/Xorg has a high CPU usage about 70% in htop.

System:    Kernel: 5.10.7-3-MANJARO x86_64 bits: 64 compiler: gcc v: 10.2.1 Desktop: KDE Plasma 5.20.5 tk: Qt 5.15.2 
           wm: kwin_x11 dm: SDDM Distro: Manjaro Linux 
Machine:   Type: Laptop System: ASUSTeK product: X450VC v: 1.0 serial: <filter> 
           Mobo: ASUSTeK model: X450VC v: 1.0 serial: <filter> BIOS: American Megatrends v: X450VC.205 date: 05/09/2013 
Battery:   ID-1: BAT0 charge: 34.8 Wh condition: 34.8/44.2 Wh (79%) volts: 14.4/14.4 model: ASUSTeK X550A30 type: Li-ion 
           serial: N/A status: Full cycles: 432 
Memory:    RAM: total: 7.66 GiB used: 2.14 GiB (27.9%) 
           RAM Report: permissions: Unable to run dmidecode. Root privileges required. 
CPU:       Info: Dual Core model: Intel Core i5-3230M bits: 64 type: MT MCP arch: Ivy Bridge rev: 9 L2 cache: 3 MiB 
           bogomips: 20761 
           Speed: 1197 MHz min/max: 1200/3200 MHz Core speeds (MHz): 1: 1197 2: 1197 3: 1195 4: 1197 
           Flags: acpi aes aperfmperf apic arat arch_perfmon avx bts clflush cmov constant_tsc cpuid cpuid_fault cx16 cx8 de 
           ds_cpl dtes64 dtherm dts epb ept erms est f16c flexpriority flush_l1d fpu fsgsbase fxsr ht ibpb ibrs ida lahf_lm lm 
           mca mce md_clear mmx monitor msr mtrr nonstop_tsc nopl nx pae pat pbe pcid pclmulqdq pdcm pebs pge pln pni popcnt 
           pse pse36 pti pts rdrand rdtscp rep_good sep smep ss ssbd sse sse2 sse4_1 sse4_2 ssse3 stibp syscall tm tm2 
           tpr_shadow tsc tsc_deadline_timer vme vmx vnmi vpid x2apic xsave xsaveopt xtopology xtpr 
Graphics:  Device-1: Intel 3rd Gen Core processor Graphics vendor: ASUSTeK driver: i915 v: kernel bus ID: 00:02.0 
           chip ID: 8086:0166 
           Device-2: NVIDIA GF117M [GeForce 610M/710M/810M/820M / GT 620M/625M/630M/720M] vendor: ASUSTeK driver: nouveau 
           v: kernel bus ID: 01:00.0 chip ID: 10de:1140 
           Device-3: Realtek Asus laptop camera type: USB driver: uvcvideo bus ID: 1-1.3:3 chip ID: 0bda:570c serial: <filter> 
           Display: x11 server: X.Org 1.20.10 compositor: kwin_x11 driver: loaded: intel,nouveau unloaded: modesetting 
           alternate: fbdev,nv,vesa resolution: 1920x1080~60Hz s-dpi: 96 
           OpenGL: renderer: Mesa DRI Intel HD Graphics 4000 (IVB GT2) v: 4.2 Mesa 20.3.3 compat-v: 3.0 direct render: Yes 
Audio:     Device-1: Intel 7 Series/C216 Family High Definition Audio vendor: ASUSTeK driver: snd_hda_intel v: kernel 
           bus ID: 00:1b.0 chip ID: 8086:1e20 
           Sound Server: ALSA v: k5.10.7-3-MANJARO 
Network:   Device-1: Qualcomm Atheros AR9485 Wireless Network Adapter vendor: Lite-On driver: ath9k v: kernel port: e000 
           bus ID: 03:00.0 chip ID: 168c:0032 
           IF: wlp3s0 state: up mac: <filter> 
           IP v4: <filter> type: dynamic noprefixroute scope: global broadcast: <filter> 
           IP v6: <filter> type: noprefixroute scope: link 
           Device-2: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet vendor: ASUSTeK driver: r8169 v: kernel port: d000 
           bus ID: 04:00.2 chip ID: 10ec:8168 
           IF: enp4s0f2 state: up speed: 100 Mbps duplex: full mac: <filter> 
           WAN IP: <filter> 
RAID:      Message: No RAID data was found. 
Drives:    Local Storage: total: 1.14 TiB used: 52.85 GiB (4.5%) 
           ID-1: /dev/sda vendor: SanDisk model: SDSSDH3 500G size: 465.76 GiB speed: 6.0 Gb/s serial: <filter> rev: 00RL 
           ID-2: /dev/sdb vendor: Seagate model: ST750LM022 HN-M750MBB size: 698.64 GiB speed: 3.0 Gb/s serial: <filter> 
           rev: 0002 
           Message: No Optical or Floppy data was found. 
Partition: ID-1: / size: 191.25 GiB used: 52.85 GiB (27.6%) fs: ext4 dev: /dev/sda2 label: N/A 
           uuid: 221646c2-7daf-4bf0-bbdb-048ea6ce109b 
Swap:      Alert: No Swap data was found. 
Unmounted: ID-1: /dev/sda1 size: 210 GiB fs: ntfs label: N/A uuid: 000F25950006D663 
           ID-2: /dev/sdb1 size: 552.15 GiB fs: ntfs label: N/A uuid: 0006603E000403B8 
USB:       Hub-1: 1-0:1 info: Full speed (or root) Hub ports: 2 rev: 2.0 speed: 480 Mb/s chip ID: 1d6b:0002 
           Hub-2: 1-1:2 info: Intel Integrated Rate Matching Hub ports: 6 rev: 2.0 speed: 480 Mb/s chip ID: 8087:0024 
           Device-1: 1-1.3:3 info: Realtek Asus laptop camera type: Video driver: uvcvideo interfaces: 2 rev: 2.0 
           speed: 480 Mb/s chip ID: 0bda:570c serial: <filter> 
           Hub-3: 2-0:1 info: Full speed (or root) Hub ports: 2 rev: 2.0 speed: 480 Mb/s chip ID: 1d6b:0002 
           Hub-4: 2-1:2 info: Intel Integrated Rate Matching Hub ports: 6 rev: 2.0 speed: 480 Mb/s chip ID: 8087:0024 
           Hub-5: 3-0:1 info: Full speed (or root) Hub ports: 4 rev: 2.0 speed: 480 Mb/s chip ID: 1d6b:0002 
           Hub-6: 3-2:2 info: Genesys Logic Hub ports: 4 rev: 2.1 speed: 480 Mb/s chip ID: 05e3:0610 
           Device-1: 3-2.1:3 info: Holtek Keyboard [Diatec Majestouch 2 Tenkeyless] type: Keyboard,Mouse 
           driver: hid-generic,usbhid interfaces: 2 rev: 1.1 speed: 1.5 Mb/s chip ID: 04d9:4545 
           Device-2: 3-2.2:4 info: [Maxxter] USB GAMING MOUSE type: Mouse,Keyboard driver: hid-generic,usbhid interfaces: 2 
           rev: 1.1 speed: 1.5 Mb/s chip ID: 18f8:1286 
           Device-3: 3-2.4:5 info: Cambridge Silicon Radio Bluetooth Dongle (HCI mode) type: Bluetooth driver: btusb 
           interfaces: 2 rev: 2.0 speed: 12 Mb/s chip ID: 0a12:0001 
           Hub-7: 4-0:1 info: Full speed (or root) Hub ports: 4 rev: 3.0 speed: 5 Gb/s chip ID: 1d6b:0003 
Sensors:   System Temperatures: cpu: 42.0 C mobo: N/A 
           Fan Speeds (RPM): cpu: 2300 
Info:      Processes: 211 Uptime: 11m wakeups: 1 Init: systemd v: 247 Compilers: gcc: 10.2.0 clang: 11.0.1 Packages: 
           pacman: 1376 Shell: Zsh v: 5.8 running in: server inxi: 3.2.02 

No wonder if you have 7(!) USB hubs connected. :woozy_face:

I’ve tried your advice, but it doesn’t work.

My laptop has 2 USB ports. I connect one of them to an USB extension cable and the other port to a USB hub which connects one mouse, one keyboard and one bluetooth adaptor.
I encounter the same problem if I directly connect the mouse and keyboard to my laptop’s 2 USB ports.

Besides, my mouse works when my keyboard freezes.

I actually found this helpful. With my ipad and cell phone plugged into my laptop to recharge, the keyboard is noticeably slower and tons of errors showed up in my typing.

Unplugging usb preipherals made my keyboard work better.