Jump to content

Adding key listener to osbot


Recommended Posts

Posted
25 minutes ago, nosepicker said:

Title says it all. Any way to write my own key listener and add it to OSBot canvas?

Can't seem to find any methods like there is for mouse listener (getBot().addMouseListener())

What Chris said, or if you only need one of keyTyped, keyPressed or keyReleased:

getBot().getCanvas().addKeyListener(new KeyAdapter() {
    @Override
    public void keyTyped(KeyEvent e) {
        super.keyTyped(e);
    }
});

I'm not sure if canvas is the correct place to add the listener, but if it works, it works I guess.

  • Like 1
Posted
16 hours ago, Explv said:

What Chris said, or if you only need one of keyTyped, keyPressed or keyReleased:


getBot().getCanvas().addKeyListener(new KeyAdapter() {
    @Override
    public void keyTyped(KeyEvent e) {
        super.keyTyped(e);
    }
});

I'm not sure if canvas is the correct place to add the listener, but if it works, it works I guess.

It works well. Thank you both.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...