Java 具有事件处理的方法会导致错误

Java 具有事件处理的方法会导致错误,java,event-handling,mouseevent,key-events,Java,Event Handling,Mouseevent,Key Events,很抱歉标题不好,但不知道还能说什么。 因此,我试图在我正在制作的游戏中添加一段代码,这样你就可以通过按任意键或使用鼠标让玩家跳跃。我几乎复制了让玩家通过按下鼠标跳跃的代码,而让玩家通过键盘键跳跃的代码(有风险,但我喜欢生活在边缘),但这给了我一个错误: The method KeyPressed(KeyEvent) from the type new KeyAdapter(){} is never used locally 由此: this.addMouseListener(n

很抱歉标题不好,但不知道还能说什么。 因此,我试图在我正在制作的游戏中添加一段代码,这样你就可以通过按任意键或使用鼠标让玩家跳跃。我几乎复制了让玩家通过按下鼠标跳跃的代码,而让玩家通过键盘键跳跃的代码(有风险,但我喜欢生活在边缘),但这给了我一个错误:

The method KeyPressed(KeyEvent) from the type new KeyAdapter(){} is never used locally
由此:

        this.addMouseListener(new MouseAdapter(){

        public void mousePressed(MouseEvent arg0) {
            player.jump();
        }

    }); 


this.addKeyListener(new KeyAdapter(){

    public void KeyPressed(KeyEvent arg0) {
        player.jump();
    }

}); 
}

我搜索了整个游戏,但没有发现其他东西里面有“鼠标”这个词,对此我也是新手。我肯定我遗漏了一些明显的东西。

按键应该是按键(以小写字母开始)。啊,是的,就是这样。我知道这是一个小错误:/