Skip to content
Snippets Groups Projects
Commit dfb68c93 authored by Dallin Nickel (djn011)'s avatar Dallin Nickel (djn011) Committed by NikolaBabic
Browse files

Create action class

parent cf131bdf
No related branches found
No related tags found
No related merge requests found
package model;
import java.awt.*;
public class Action extends Hotkey implements InputEmulator{
/**
* Robot which simulates user key presses
*/
Robot robot;
/**
* Constructs an immutable hotkey.
* @param keyCode The virtual keycode of the hotkey.
* @param id The unique ID of the hotkey.
* @param modifier The modifier of the hotkey.
*/
public Action(int keyCode, int id, Modifier modifier) throws AWTException {
super(keyCode, id, modifier);
this.robot = new Robot();
}
/**
* Sends a given key to be emulated.
* @param keyCode The virtual keycode of the key.
* @param release True if the key is to be a key release input.
*/
@Override
public void sendKey(int keyCode, boolean release) {
if (release) {
robot.keyPress(this.getKeyCode());
robot.keyRelease(this.getKeyCode());
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment