# Is there a hasFocus property or method on the plugin UI controls?

**URL:** <https://forums.creativeclouddeveloper.com/t/is-there-a-hasfocus-property-or-method-on-the-plugin-ui-controls/271>\
**Category:** UXP Plugin API\
**Tags:** ui, events\
**Created:** [October 24, 2018, 4:42am UTC](https://forums.creativeclouddeveloper.com/t/is-there-a-hasfocus-property-or-method-on-the-plugin-ui-controls/271 "2018-10-24T04:42:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Velara](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/velara/32/1278_2.png) [@Velara](https://forums.creativeclouddeveloper.com/u/Velara)\
**Post date:** [October 24, 2018, 4:42am UTC](https://forums.creativeclouddeveloper.com/t/is-there-a-hasfocus-property-or-method-on-the-plugin-ui-controls/271/1 "2018-10-24T04:42:04Z")

</div>

I’m trying to find if a text input has focus when the enter key is pressed (form submit).

Is there a hasFocus property on the UI components?

Or is there a property on the form submit event that refers to the target that has focus? The currentTarget is referring to the button even when another input has focus when I press the enter key.

---

<div class="post-metadata">

**Author:** ![kerrishotts](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/kerrishotts/32/8_2.png) [@kerrishotts](https://forums.creativeclouddeveloper.com/u/kerrishotts)\
**Post date:** [October 24, 2018, 2:11pm UTC](https://forums.creativeclouddeveloper.com/t/is-there-a-hasfocus-property-or-method-on-the-plugin-ui-controls/271/2 "2018-10-24T14:11:35Z")

</div>

Hmm… not at the moment I don’t think. Once we have `:focus` pseudo selector, you could get the currently focused control that way. We also don’t have `document.activeElement` yet.

If you’re trying to prevent ENTER from working while a text field is focused, you _can_ use the `keydown` event on text fields and just call `evt.preventDefault()` if the key code is `13`.
