Another keyboard option (if you have the space):
I have an entire second keyboard and all keys can be set as programmable keys. It's a Corsair keyboard with iCue software. The software can be set to work with the Corsair keyboard only so I have the "normal" keyboard and then an entire extra keyboard for function/macro keys. I made a "cradle" for the 2nd keyboard from a cardbard box and it sits tight just behind and above the main keyboard. I then print keytop labels and paste them on with a glue stick. It works great.
Of course, there are many optons similiar to this (as given above)... this is simply another option.
I have changed all the Power Management settings in Windows 11. I have experienced some improvement, but there are still times, not as frequently, when I do have keyboard lag. I found the following link that discusses other settings and diagnostics that I hope will resolve all the lagging. Otherwise I will be fed-up with Microsoft for its draconian implementation of Ease of Access (I do use the Magnifier) and destroying effective usefulness of its Edge browser. I purchased a computer only to have corporate greed take control of my computer? I jest, but not entirely. I am just at a loss of patience.