# hitTestObject with Keyboard

**URL:** https://forum.kirupa.com/t/hittestobject-with-keyboard/275928
**Category:** flash
**Created:** [November 20, 2008, 6:50am UTC](https://forum.kirupa.com/t/hittestobject-with-keyboard/275928 "2008-11-20T06:50:00Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![wjordan1987](https://avatars.discourse-cdn.com/v4/letter/w/c57346/32.png) [@wjordan1987](https://forum.kirupa.com/u/wjordan1987)
#### Post date: [November 20, 2008, 6:50am UTC](https://forum.kirupa.com/t/hittestobject-with-keyboard/275928/1 "2008-11-20T06:50:00Z")

</div>

I have made an avatar that can move from left to right via the keyboard. I want a hitTestObject so when the avatar hits a specific object something happens. I understand how to do this with MouseEvents, but not KeyboardEvents.

Such as:

avatar.addEventListener(MouseEvent.MOUSE\_OVER , mOver);  
function mOver(event:MouseEvent):void {  
event.target.startDrag();  
if(event.target.hitTestObject(ball) && event.target.name == “avatar”) {  
ball.visible = false;  
}  
}
