# overriding NativeOnPreviewKeyDown works but not NativeOnKeyChar

**URL:** <https://forums.unrealengine.com/t/overriding-nativeonpreviewkeydown-works-but-not-nativeonkeychar/486597>\
**Category:** UI\
**Tags:** override, unreal-engine, UI, Widget, question\
**Created:** [July 25, 2021, 7:09pm UTC](https://forums.unrealengine.com/t/overriding-nativeonpreviewkeydown-works-but-not-nativeonkeychar/486597 "2021-07-25T19:09:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![MrLloyd88](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MrLloyd88](https://forums.unrealengine.com/u/MrLloyd88)\
**Post date:** [July 25, 2021, 7:09pm UTC](https://forums.unrealengine.com/t/overriding-nativeonpreviewkeydown-works-but-not-nativeonkeychar/486597/1 "2021-07-25T19:09:25Z")

</div>

Im already overriding NativeOnPreviewKeyDown which works fine.  
If i try to do the same thing with NativeOnKeyChar it doesnt seem to fire.  
header-

```
// catch keyboard presses before text input handles them
	virtual FReply NativeOnPreviewKeyDown(const FGeometry& InGeometry, const FKeyEvent& InKeyEvent) override;

	virtual FReply NativeOnKeyChar(const FGeometry& InGeometry, const FCharacterEvent& InCharEvent) override;

```

cpp-

```
FReply UCodeEditor::NativeOnPreviewKeyDown(const FGeometry& InGeometry, const FKeyEvent& InKeyEvent)
{
	//return focus to game to automatically fire off commitinputtext
	if (InKeyEvent.GetKey().ToString() == "LeftControl")
	{
		UE_LOG(LogTemp, Warning, TEXT("code editor handling left control"));
		UWidgetBlueprintLibrary::SetFocusToGameViewport();
		return FReply::Handled();
	};

	return FReply::Unhandled();
}

FReply UCodeEditor::NativeOnKeyChar(const FGeometry& InGeometry, const FCharacterEvent& InCharEvent)
{
	UE_LOG(LogTemp, Warning, TEXT("from text input: %s"), InCharEvent.GetCharacter());

	return FReply::Unhandled();
}
```
