No, you can't use local variables like that. Local variables can only store their value until the end of the tick (unless you set them as static). That's why your object disappears - by the time you press Z button, both H and W are 0. And when you do "Sprite Set size to (w-16,h-16)", you set width and height to negative -16.
If you change the variables to global (move outside the group), your code should work.
Here is what I meant - local variables are used for temporary storage and only inside this event: