Implementare pentru buton ce poate fi apăsat de o tastă

#include <graphics.h>
#include <winbgim.h>

using namespace std;
#define MAX 50
#define APASAT 1
#define RELAXAT 2

struct buton
{
 char text[MAX];
 int marime;
 int x,y;
 int x1,y1,x2,y2;
};

void initButon(buton& b, char text0[MAX], int x0, int y0, int m0)
{
 strcpy(b.text,text0);
 b.x=x0;
 b.y=y0;
 b.marime=m0;
 settextstyle(SIMPLEX_FONT,HORIZ_DIR,b.marime);
 b.x1=x0-textwidth(b.text)/2-5;
 b.x2=x0+textwidth(b.text)/2+5;
 b.y1=y0-textheight(b.text)/2-5;;
 b.y2=y0+textheight(b.text)/2+5;
}

void deseneazaButon(buton b, int stil)
{
 settextstyle(SIMPLEX_FONT, HORIZ_DIR, b.marime);
 setcolor(COLOR(255, 204, 102));
 setfillstyle(SOLID_FILL,COLOR(255, 204, 102));
 bar(b.x1,b.y1,b.x2,b.y2);
 settextjustify(CENTER_TEXT, CENTER_TEXT);
 if (stil==RELAXAT)
 {
 setbkcolor(COLOR(255, 204, 102));
 setcolor(BLACK);
 outtextxy((b.x1+b.x2)/2,(b.y1+b.y2)/2+2,b.text);
 setcolor(WHITE);
 line(b.x1-1,b.y1-1,b.x2-1,b.y1-1);
 line(b.x1-1,b.y1-1,b.x1-1,b.y2-1);
 setcolor(COLOR(230, 153, 0));
 line(b.x1+1,b.y2+1,b.x2+1,b.y2+1);
 line(b.x2+1,b.y1+1,b.x2+1,b.y2+1);
 }
 else
 {
 setbkcolor(COLOR(255, 204, 102));
 setcolor(BLACK);
 outtextxy((b.x1+b.x2)/2+2,(b.y1+b.y2)/2+4,b.text);
 setcolor(WHITE);
 line(b.x1+1,b.y2+1,b.x2+1,b.y2+1);
 line(b.x2+1,b.y1+1,b.x2+1,b.y2+1);
 setcolor(COLOR(230, 153, 0));
 line(b.x1-1,b.y1-1,b.x2-1,b.y1-1);
 line(b.x1-1,b.y1-1,b.x1-1,b.y2-1);
 }
}

int main()
{
 initwindow(800,600);
 setbkcolor(WHITE);
 cleardevice();
 buton b;
 initButon(b,"Apasa",400,300,2);
 char tasta;
 do {
 deseneazaButon(b,RELAXAT);
 tasta=getch();
 deseneazaButon(b,APASAT);
 delay(250);
 } while (tasta!=27);
 closegraph();
 return 0;
}