I have had some luck and some disappointment with various BT keyboards working properly with RetroPie. The first two I bought worked perfectly, so I ordered a couple more from the same vendor, while they did pair successfully, the function keys wouldn't work. I noticed even through they looked identical, the model numbers were different, so I requested the model numbers that I knew specifically worked. Long story short and 8 keyboards later, they were unable to deliver any fully functioning keyboards... so I widened the net and ordered eight more from various vendors, four of which provided me with compatible keyboards. Here they are on Amazon:
$14 CyberTech Bluetooth Ultra-Thin
$15 Fintie Ultra Slim Wireless Bluetooth
$20 Anker Bluetooth Ultra-Slim
$18 Jelly Comb Universal Backlit
Clearly most of these are the same models from China with company branding, but it seems the programming or on-board drivers are slightly different per company too.
Also, if you're having difficulty pairing your keyboards, here is a little CNET article on how to setup bluetooth directly in Linux (vs. the RetroPie setup GUI). The GUI method was spotty for me but the Linux method worked 100% of the time! (note: it was sometimes necessary to slip a "trust xx:xx:xx:xx:xx:xx" between the "pair" and "connect" commands)
My work/fail test was to be in EmulationStation and hit the F4 key. If it doesn't exit EmulationStation it was a fail. (some keyboards required a two key press of FN and F4). If you are already in the Linux shell you can type "showkey -a" and then press F4, compare the result with a USB wired keyboard press of F4. If they are not the same, fail the keyboard.