Using whileHeld() would be an equivalent approach than making whenPressed() turn it on and whenReleased() turn it off. To make it toggle you need a command to somehow change the shooter's state based on a current state. I expect your shooter has some setRunning() and isRunning() (the methods might be different -- the important part is being able to tell whether or not the shooter is running). The logic you want (probably in initialize()) is this:
Code:
if(shooter is shooting) {
turn shooter off;
} else {
turn shooter on;
}
If your shooter is a PIDSubsystem, you can do something like this:
Code:
if(shooter.getSetpoint() != 0) {
shooter.setSetpoint(shooterSpeed);
} else {
shooter.setSetpoint(0);
}