What exactly is shutting down: the emulator, emulationstation, or does the entire system turn off?
Retroarch recognizes keyboards different from joypads, and I’m not sure it’ll recognize the term “joystick” at all (but I’ll abdicate that to people more versed in coding than me). The retroarch.cfg file should actually be set to detect a keyboard input as the default, so it shouldn’t need much (if any) setup.