You may get a notification when the keyboard battery level drops to around 2%. If this is an Apple Magic Keyboard, plug it into a power source and continue using it as it recharges. Otherwise, replace the batteries if so configured.
Copy and paste the following into the Terminal application, followed by a return. It will show the percentage value at which you will receive a low battery notification and the current battery percentage. If you have an Apple Magic Mouse and Magic Keyboard in use, it will show these values in that order:
ioreg -r -l -k "BatteryPercent" | grep -io '("LowBatteryNotificationPercentage"|"BatteryPercent") = \d+'
On my 2023 M2 Mac Mini Pro with Ventura 13.5.1 and both Magic Keyboard and mouse connected, this is my result, again with the keyboard shown first and the mouse second.
"LowBatteryNotificationPercentage" = 2
"BatteryPercent" = 96
"LowBatteryNotificationPercentage" = 2
"BatteryPercent" = 93