Can you help me refactor this code:
public void keyPressed(KeyEvent e)
{
if (e.getKeyCode()==39)
{
//Right arrow key code
}
else if (e.getKeyCode()==37)
{
//Left arrow key code
}
repaint();
}
Please mention how to check for up/down arrow keys as well.Thanks!