# How to register ESC or Tab when widget text box has keyboard focus?

**URL:** <https://forums.unrealengine.com/t/how-to-register-esc-or-tab-when-widget-text-box-has-keyboard-focus/448482>\
**Category:** UI\
**Tags:** text-box, Input, unreal-engine, Widget, Blueprint, question\
**Created:** [May 6, 2019, 2:21pm UTC](https://forums.unrealengine.com/t/how-to-register-esc-or-tab-when-widget-text-box-has-keyboard-focus/448482 "2019-05-06T14:21:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![crystal6tak](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@crystal6tak](https://forums.unrealengine.com/u/crystal6tak)\
**Post date:** [May 6, 2019, 2:21pm UTC](https://forums.unrealengine.com/t/how-to-register-esc-or-tab-when-widget-text-box-has-keyboard-focus/448482/1 "2019-05-06T14:21:11Z")

</div>

Hello all!

I am building a chat box in a multiplayer project. I want to make it so after typing and sending your message, pressing ESC refocuses to game. (and eventually pressing TAB to switch between all chat and team chat.)

I can’t figure out how to detect ESC or Tab input when text box has keyboard focus.

Here’s my setup:  
In event begin play, I’m setting input mode to game only:

![276123-eventbeginplay.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/c/b/3cb2e6620f5269ce5f46f998359b92754161c713.png)

Then, by pressing T, it focuses to chat text box, so I can immediately start typing a message without having to click the text box with my mouse:

 ![276125-set-focus.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/1/8/6184269e483f9deaf89317c95df4aa6c3f9754c9.png)

Then, here’s what ESC is bound to do in player controller:

 ![276126-what-esc-do.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/b/b/8bb4d47b12cb74ffe0d0dd34b80782c6d2d5f7ca.png)

I have this debug print string setup on event tick to monitor what the widget has in focus:

 ![276127-focus-check.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/3/6/636835e80f139ca408cdd552e9c06a70e359703b.png)

Here’s what my results are:

Right as I go in game, where I can control my player:  
**Any user focus: false/ Has user focus: false/ Keyboard focus: false**

Pressing T once, where I can now type a message:  
**Any user focus: false/ Has user focus: false/ Keyboard focus: true**

Pressing ESC once, now I’m stuck in some weird interface mode where WASD registers my character movement input, but my mouse is free to move around, and if I want to look around as player, I have to right click drag the screen (I’m using third person BP template). I can use my mouse to click the textbox to focus back on it.  
**Any user focus: true/ Has user focus: true/ Keyboard focus: true**

Pressing ESC twice, does my intended effect, bringing me back to game only input.  
**Any user focus: false/ Has user focus: false/ Keyboard focus: false**

This tells me somewhere is consuming my ESC input (and Tab input) before my player controller can handle it. Anyone know where and how I can modify it to do what I want?

Thank you!
