private void addKeyListener(Component c, KeyListener kl) {
        c.addKeyListener(kl);
        if (c instanceof JFrame) {
            for (Component comp : ((JFrame) c).getComponents()) {
                addKeyListener(comp, kl);
            }
        } else if (c instanceof JPanel) {
            for (Component comp : ((JPanel) c).getComponents()) {
                addKeyListener(comp, kl);
            }
        } else if (c instanceof JComponent) {
            for (Component comp : ((JComponent) c).getComponents()) {
                addKeyListener(comp, kl);
            }
        }
    }