Added keyboard press detection