Platformer Jumping

Hi all, I’m new to this forum and ActionScript itself (just started late yesterday)

What I’m trying to do is make a simple platformer, and so far, things are going well. I have a character, ground, gravity, and left/right movement. But, I cannot seem to get jumping working. When I try to jump by pressing the W key, my character rises at an exponential rate and flies out of the top of the screen. It’s supposed to rise exponentially, but fall back down once it reaches a “speed” of 10. Any help as to why this happens would be VERY much appreaciated.

var velx = 0;
var vely = 0.1;
var grav = 5;
var jumping = false;
import flash.events.KeyboardEvent;
import flash.events.Event;

char.stop();
stage.addEventListener(KeyboardEvent.KEY_DOWN, keys);
stage.addEventListener(Event.ENTER_FRAME, cmove);
function keys(e:KeyboardEvent):void {
    if (e.keyCode == 65) {
        velx = -10;
        char.gotoAndStop(2);
    }
    if (e.keyCode == 68) {
        velx = 10;
        char.gotoAndStop(1);
    }
    if (e.keyCode == 87) {
        vely = -2;
        jumping = true;
    }
}
function cmove(e:Event):void {
    char.x += velx;
    if (velx < 1 && velx > -1) {
        velx = 0;
    } else {
    velx *= 0.85;
    }
    if (!char.hitTestObject(ground) || jumping) {
        char.y += vely + grav;
        if (vely >= 10) {
            vely = 10;
        } else {
            vely = vely * 1.25;
            if (vely > 10) {
                jumping = false;
                vely = 0.1;
            }
        }
    }
}