Start with reading this in the manual:
https://docs.darktable.org/usermanual/4.6/en/special-topics/midi-device-support/
Then do as darix indicated and search the forum for loupdeck and MIDI. As far as I remember the latest with substance on this topic has been the loupdeck settings from @hannoschwalm.
EDIT: You find the latter here: Midi Controller for Darktable - #103 by hannoschwalm