Ah yes, this is a case where the mouse coordinates can sometimes update faster than the code can use the ones it thinks they are. This is solved by treating mouse_x and mouse_y as a poll value. Then you make your own variables for keeping track of what you are doing with the mouse.
int mymousex, mymouxey;
if(mouse_b & 1)
mymousex=mouse_x; // as of the button press.
mymousey=mouse_y; // as of the button press.
/* Draw & set a tile */
if((mymousex < mapX*PCX_X) && (mymousey < mapY*PCX_Y))
map.SetTile(mymousex/PCX_X, mymousey/PCX_Y, (TILE)tile); // just an insertion to an array
map.UpdateTile(mymousex/PCX_X, mymousey/PCX_Y); // -> blit
EDIT: See next post.
As for install_keyboard_hooks(), I would not recommend using it really, for simplicities sake. If you would rather use another keyboard handler, just don't use the install_keyboard() function, but rather take care of the keyboard stuff as you normally would with whatever handler you choose.