In this program, when the button is let go there is a delay from when the led turns back on. How can i prevent this?

int ledPin = 13; // choose the pin for the LED
int inPin = 2; // choose the input pin (for a pushbutton)
int val = 0; // variable for reading the pin status

void setup() {
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inPin, INPUT); // declare pushbutton as input

void loop(){
val = digitalRead(inPin); // read input value
if (val == HIGH) { // check if the input is HIGH (button released)
digitalWrite(ledPin, LOW); // turn LED OFF
} else {
digitalWrite(ledPin, HIGH); // turn LED ON

How is your button wired up?

Sounds like you have a 'floating' input when the switch is inactive. The simpest way to wire a switch is from the pin to ground and activate the internal pull-ups for that input and finally switch the logic to make a low be the active on state. However even then you should read up on switch contact bounce in the Arduino playground (input section, mechanical topic) section and think about using the a debounce libary function.