Fix exceptions if keys pressed while no task is selected

Null pointer exceptions were thrown if X, D, U or P were pressed while
no task was selected in the list box. For instance this happens when
the todo list is empty. Guard clauses have been added to prevent the
commands to execute when no task is selected.