Created a single function to add key handling callbacks.