Added methods for handling keyboard and mouse events