Way to make something move with keypresses?

using keyarray or other ways which i'm not aware of?

I wanted to know because i'm starting to make a little platformer, and the other question is..

How would i make it possible for enemies to attack me and then i lose health?

Any help appreciated, thanks