Added functionality for key handling