Looking at a replacement keyboard on amazon, it looks like there are 2 ribbon cables. You may need to reseat both ribbon cables as one might not be seating properly. Another possibility is that you might have ripped one of the ribbon cables, shorted something on your motherboard, or damaged the motherboard with static electricity. If you were careful and removed the battery then it's unlikely it's due to a short. Depending on the humidity in your area you may not have to worry as much about static. For me, I live in the Pacific northwest and the humidity is so high that I never wear wrist grounding straps when I work on electronics. If it's a low humidity area then it's a good idea to wear one though.
Hopefully it's that other ribbon cable needs to be reseated. Best of luck!
Link to keyboard on amazon to use as reference: https://www.amazon.com/Replacement-Keyboard-Alienware-Laptop-Backlit/dp/B09C5S9X7G/ref=sr\_1\_1\_sspa?keywords=alienware+17+r4+keyboard&qid=1644786027&sr=8-1-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUFORlJWQk9CMFZRMFUmZW5jcnlwdGVkSWQ9QTAyOTQzNjhJRzJJRFVFREVCSUwmZW5jcnlwdGVkQWRJZD1BMDQ5NTIzNU9HVjlUUkNGQVQ4MiZ3aWRnZXROYW1lPXNwX2F0ZiZhY3Rpb249Y2xpY2tSZWRpcmVjdCZkb05vdExvZ0NsaWNrPXRydWU=