Keybinding to a specific task

Probably a newbie question, but can I create a keybinding to a specific task? Like I'd want a shortcut for running
npm dev
in an astro project
Was this page helpful?