diff --git a/Telegram/SourceFiles/info/info_layer_widget.cpp b/Telegram/SourceFiles/info/info_layer_widget.cpp
index ff311121d..bd3667b24 100644
--- a/Telegram/SourceFiles/info/info_layer_widget.cpp
+++ b/Telegram/SourceFiles/info/info_layer_widget.cpp
@@ -190,6 +190,10 @@ int LayerWidget::resizeGetHeight(int newWidth) {
 	return desiredHeight;
 }
 
+void LayerWidget::doSetInnerFocus() {
+	_content->setInnerFocus();
+}
+
 void LayerWidget::paintEvent(QPaintEvent *e) {
 	Painter p(this);
 
diff --git a/Telegram/SourceFiles/info/info_layer_widget.h b/Telegram/SourceFiles/info/info_layer_widget.h
index 80d289227..c3c331fb9 100644
--- a/Telegram/SourceFiles/info/info_layer_widget.h
+++ b/Telegram/SourceFiles/info/info_layer_widget.h
@@ -41,6 +41,7 @@ public:
 
 protected:
 	int resizeGetHeight(int newWidth) override;
+	void doSetInnerFocus() override;
 
 	void paintEvent(QPaintEvent *e) override;
 
diff --git a/Telegram/SourceFiles/old_settings/settings_widget.cpp b/Telegram/SourceFiles/old_settings/settings_widget.cpp
index ade50a752..38042d7a3 100644
--- a/Telegram/SourceFiles/old_settings/settings_widget.cpp
+++ b/Telegram/SourceFiles/old_settings/settings_widget.cpp
@@ -35,176 +35,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 #include "styles/style_boxes.h"
 
 namespace OldSettings {
-namespace {
-
-QString SecretText;
-QMap<QString, Fn<void()>> Codes;
-
-void fillCodes() {
-	Codes.insert(qsl("debugmode"), [] {
-		QString text = Logs::DebugEnabled()
-			? qsl("Do you want to disable DEBUG logs?")
-			: qsl("Do you want to enable DEBUG logs?\n\n"
-				"All network events will be logged.");
-		Ui::show(Box<ConfirmBox>(text, [] {
-			Messenger::Instance().onSwitchDebugMode();
-		}));
-	});
-	Codes.insert(qsl("viewlogs"), [] {
-		File::ShowInFolder(cWorkingDir() + "log.txt");
-	});
-	Codes.insert(qsl("testmode"), [] {
-		auto text = cTestMode() ? qsl("Do you want to disable TEST mode?") : qsl("Do you want to enable TEST mode?\n\nYou will be switched to test cloud.");
-		Ui::show(Box<ConfirmBox>(text, [] {
-			Messenger::Instance().onSwitchTestMode();
-		}));
-	});
-	if (!Core::UpdaterDisabled()) {
-		Codes.insert(qsl("testupdate"), [] {
-			Core::UpdateChecker().test();
-		});
-	}
-	Codes.insert(qsl("loadlang"), [] {
-		Lang::CurrentCloudManager().switchToLanguage(qsl("custom"));
-	});
-	Codes.insert(qsl("debugfiles"), [] {
-		if (!Logs::DebugEnabled()) {
-			return;
-		}
-		if (DebugLogging::FileLoader()) {
-			Global::RefDebugLoggingFlags() &= ~DebugLogging::FileLoaderFlag;
-		} else {
-			Global::RefDebugLoggingFlags() |= DebugLogging::FileLoaderFlag;
-		}
-		Ui::show(Box<InformBox>(DebugLogging::FileLoader() ? qsl("Enabled file download logging") : qsl("Disabled file download logging")));
-	});
-	Codes.insert(qsl("crashplease"), [] {
-		Unexpected("Crashed in Settings!");
-	});
-	Codes.insert(qsl("workmode"), [] {
-		auto text = Global::DialogsModeEnabled() ? qsl("Disable work mode?") : qsl("Enable work mode?");
-		Ui::show(Box<ConfirmBox>(text, [] {
-			Messenger::Instance().onSwitchWorkMode();
-		}));
-	});
-	Codes.insert(qsl("moderate"), [] {
-		auto text = Global::ModerateModeEnabled() ? qsl("Disable moderate mode?") : qsl("Enable moderate mode?");
-		Ui::show(Box<ConfirmBox>(text, []() {
-			Global::SetModerateModeEnabled(!Global::ModerateModeEnabled());
-			Local::writeUserSettings();
-			Ui::hideLayer();
-		}));
-	});
-	Codes.insert(qsl("getdifference"), [] {
-		if (auto main = App::main()) {
-			main->getDifference();
-		}
-	});
-	Codes.insert(qsl("loadcolors"), [] {
-		FileDialog::GetOpenPath(Messenger::Instance().getFileDialogParent(), "Open palette file", "Palette (*.tdesktop-palette)", [](const FileDialog::OpenResult &result) {
-			if (!result.paths.isEmpty()) {
-				Window::Theme::Apply(result.paths.front());
-			}
-		});
-	});
-	Codes.insert(qsl("edittheme"), [] {
-		Window::Theme::Editor::Start();
-	});
-	Codes.insert(qsl("videoplayer"), [] {
-		auto text = cUseExternalVideoPlayer() ? qsl("Use internal video player?") : qsl("Use external video player?");
-		Ui::show(Box<ConfirmBox>(text, [] {
-			cSetUseExternalVideoPlayer(!cUseExternalVideoPlayer());
-			Local::writeUserSettings();
-			Ui::hideLayer();
-		}));
-	});
-	Codes.insert(qsl("endpoints"), [] {
-		FileDialog::GetOpenPath(Messenger::Instance().getFileDialogParent(), "Open DC endpoints", "DC Endpoints (*.tdesktop-endpoints)", [](const FileDialog::OpenResult &result) {
-			if (!result.paths.isEmpty()) {
-				if (!Messenger::Instance().mtp()->dcOptions()->loadFromFile(result.paths.front())) {
-					Ui::show(Box<InformBox>("Could not load endpoints :( Errors in 'log.txt'."));
-				}
-			}
-		});
-	});
-	Codes.insert(qsl("registertg"), [] {
-		Platform::RegisterCustomScheme();
-		Ui::Toast::Show("Forced custom scheme register.");
-	});
-	Codes.insert(qsl("export"), [] {
-		Auth().data().startExport();
-	});
-
-	auto audioFilters = qsl("Audio files (*.wav *.mp3);;") + FileDialog::AllFilesFilter();
-	auto audioKeys = {
-		qsl("msg_incoming"),
-		qsl("call_incoming"),
-		qsl("call_outgoing"),
-		qsl("call_busy"),
-		qsl("call_connect"),
-		qsl("call_end"),
-	};
-	for (auto &key : audioKeys) {
-		Codes.insert(key, [audioFilters, key] {
-			if (!AuthSession::Exists()) {
-				return;
-			}
-
-			FileDialog::GetOpenPath(Messenger::Instance().getFileDialogParent(), "Open audio file", audioFilters, [key](const FileDialog::OpenResult &result) {
-				if (AuthSession::Exists() && !result.paths.isEmpty()) {
-					auto track = Media::Audio::Current().createTrack();
-					track->fillFromFile(result.paths.front());
-					if (track->failed()) {
-						Ui::show(Box<InformBox>("Could not audio :( Errors in 'log.txt'."));
-					} else {
-						Auth().settings().setSoundOverride(key, result.paths.front());
-						Local::writeUserSettings();
-					}
-				}
-			});
-		});
-	}
-	Codes.insert(qsl("sounds_reset"), [] {
-		if (AuthSession::Exists()) {
-			Auth().settings().clearSoundOverrides();
-			Local::writeUserSettings();
-			Ui::show(Box<InformBox>("All sound overrides were reset."));
-		}
-	});
-}
-
-void codesFeedString(const QString &text) {
-	if (Codes.isEmpty()) fillCodes();
-
-	SecretText += text.toLower();
-	int size = SecretText.size(), from = 0;
-	while (size > from) {
-		auto piece = SecretText.midRef(from);
-		auto found = false;
-		for (auto i = Codes.cbegin(), e = Codes.cend(); i != e; ++i) {
-			if (piece == i.key()) {
-				(*i)();
-				from = size;
-				found = true;
-				break;
-			}
-		}
-		if (found) break;
-
-		for (auto i = Codes.cbegin(), e = Codes.cend(); i != e; ++i) {
-			if (i.key().startsWith(piece)) {
-				found = true;
-				break;
-			}
-		}
-		if (found) break;
-
-		++from;
-	}
-	SecretText = (size > from) ? SecretText.mid(from) : QString();
-}
-
-} // namespace
 
 Widget::Widget(QWidget *parent) {
 	refreshLang();
@@ -229,7 +59,6 @@ void Widget::scrollToUpdateRow() {
 }
 
 void Widget::keyPressEvent(QKeyEvent *e) {
-	codesFeedString(e->text());
 	return LayerWidget::keyPressEvent(e);
 }
 
diff --git a/Telegram/SourceFiles/settings/settings_codes.cpp b/Telegram/SourceFiles/settings/settings_codes.cpp
new file mode 100644
index 000000000..cf83c16c4
--- /dev/null
+++ b/Telegram/SourceFiles/settings/settings_codes.cpp
@@ -0,0 +1,192 @@
+/*
+This file is part of Telegram Desktop,
+the official desktop application for the Telegram messaging service.
+
+For license and copyright information please follow this link:
+https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
+*/
+#include "settings/settings_codes.h"
+
+#include "platform/platform_specific.h"
+#include "ui/toast/toast.h"
+#include "mainwidget.h"
+#include "data/data_session.h"
+#include "storage/localstorage.h"
+#include "boxes/confirm_box.h"
+#include "lang/lang_cloud_manager.h"
+#include "messenger.h"
+#include "mtproto/mtp_instance.h"
+#include "mtproto/dc_options.h"
+#include "core/file_utilities.h"
+#include "core/update_checker.h"
+#include "window/themes/window_theme.h"
+#include "window/themes/window_theme_editor.h"
+#include "media/media_audio_track.h"
+
+namespace Settings {
+
+auto GenerateCodes() {
+	auto codes = std::map<QString, Fn<void()>>();
+	codes.emplace(qsl("debugmode"), [] {
+		QString text = Logs::DebugEnabled()
+			? qsl("Do you want to disable DEBUG logs?")
+			: qsl("Do you want to enable DEBUG logs?\n\n"
+				"All network events will be logged.");
+		Ui::show(Box<ConfirmBox>(text, [] {
+			Messenger::Instance().onSwitchDebugMode();
+		}));
+	});
+	codes.emplace(qsl("viewlogs"), [] {
+		File::ShowInFolder(cWorkingDir() + "log.txt");
+	});
+	codes.emplace(qsl("testmode"), [] {
+		auto text = cTestMode() ? qsl("Do you want to disable TEST mode?") : qsl("Do you want to enable TEST mode?\n\nYou will be switched to test cloud.");
+		Ui::show(Box<ConfirmBox>(text, [] {
+			Messenger::Instance().onSwitchTestMode();
+		}));
+	});
+	if (!Core::UpdaterDisabled()) {
+		codes.emplace(qsl("testupdate"), [] {
+			Core::UpdateChecker().test();
+		});
+	}
+	codes.emplace(qsl("loadlang"), [] {
+		Lang::CurrentCloudManager().switchToLanguage(qsl("custom"));
+	});
+	codes.emplace(qsl("debugfiles"), [] {
+		if (!Logs::DebugEnabled()) {
+			return;
+		}
+		if (DebugLogging::FileLoader()) {
+			Global::RefDebugLoggingFlags() &= ~DebugLogging::FileLoaderFlag;
+		} else {
+			Global::RefDebugLoggingFlags() |= DebugLogging::FileLoaderFlag;
+		}
+		Ui::show(Box<InformBox>(DebugLogging::FileLoader() ? qsl("Enabled file download logging") : qsl("Disabled file download logging")));
+	});
+	codes.emplace(qsl("crashplease"), [] {
+		Unexpected("Crashed in Settings!");
+	});
+	codes.emplace(qsl("workmode"), [] {
+		auto text = Global::DialogsModeEnabled() ? qsl("Disable work mode?") : qsl("Enable work mode?");
+		Ui::show(Box<ConfirmBox>(text, [] {
+			Messenger::Instance().onSwitchWorkMode();
+		}));
+	});
+	codes.emplace(qsl("moderate"), [] {
+		auto text = Global::ModerateModeEnabled() ? qsl("Disable moderate mode?") : qsl("Enable moderate mode?");
+		Ui::show(Box<ConfirmBox>(text, []() {
+			Global::SetModerateModeEnabled(!Global::ModerateModeEnabled());
+			Local::writeUserSettings();
+			Ui::hideLayer();
+		}));
+	});
+	codes.emplace(qsl("getdifference"), [] {
+		if (auto main = App::main()) {
+			main->getDifference();
+		}
+	});
+	codes.emplace(qsl("loadcolors"), [] {
+		FileDialog::GetOpenPath(Messenger::Instance().getFileDialogParent(), "Open palette file", "Palette (*.tdesktop-palette)", [](const FileDialog::OpenResult &result) {
+			if (!result.paths.isEmpty()) {
+				Window::Theme::Apply(result.paths.front());
+			}
+		});
+	});
+	codes.emplace(qsl("edittheme"), [] {
+		Window::Theme::Editor::Start();
+	});
+	codes.emplace(qsl("videoplayer"), [] {
+		auto text = cUseExternalVideoPlayer() ? qsl("Use internal video player?") : qsl("Use external video player?");
+		Ui::show(Box<ConfirmBox>(text, [] {
+			cSetUseExternalVideoPlayer(!cUseExternalVideoPlayer());
+			Local::writeUserSettings();
+			Ui::hideLayer();
+		}));
+	});
+	codes.emplace(qsl("endpoints"), [] {
+		FileDialog::GetOpenPath(Messenger::Instance().getFileDialogParent(), "Open DC endpoints", "DC Endpoints (*.tdesktop-endpoints)", [](const FileDialog::OpenResult &result) {
+			if (!result.paths.isEmpty()) {
+				if (!Messenger::Instance().mtp()->dcOptions()->loadFromFile(result.paths.front())) {
+					Ui::show(Box<InformBox>("Could not load endpoints :( Errors in 'log.txt'."));
+				}
+			}
+		});
+	});
+	codes.emplace(qsl("registertg"), [] {
+		Platform::RegisterCustomScheme();
+		Ui::Toast::Show("Forced custom scheme register.");
+	});
+	codes.emplace(qsl("export"), [] {
+		Auth().data().startExport();
+	});
+
+	auto audioFilters = qsl("Audio files (*.wav *.mp3);;") + FileDialog::AllFilesFilter();
+	auto audioKeys = {
+		qsl("msg_incoming"),
+		qsl("call_incoming"),
+		qsl("call_outgoing"),
+		qsl("call_busy"),
+		qsl("call_connect"),
+		qsl("call_end"),
+	};
+	for (auto &key : audioKeys) {
+		codes.emplace(key, [audioFilters, key] {
+			if (!AuthSession::Exists()) {
+				return;
+			}
+
+			FileDialog::GetOpenPath(Messenger::Instance().getFileDialogParent(), "Open audio file", audioFilters, [key](const FileDialog::OpenResult &result) {
+				if (AuthSession::Exists() && !result.paths.isEmpty()) {
+					auto track = Media::Audio::Current().createTrack();
+					track->fillFromFile(result.paths.front());
+					if (track->failed()) {
+						Ui::show(Box<InformBox>("Could not audio :( Errors in 'log.txt'."));
+					} else {
+						Auth().settings().setSoundOverride(key, result.paths.front());
+						Local::writeUserSettings();
+					}
+				}
+			});
+		});
+	}
+	codes.emplace(qsl("sounds_reset"), [] {
+		if (AuthSession::Exists()) {
+			Auth().settings().clearSoundOverrides();
+			Local::writeUserSettings();
+			Ui::show(Box<InformBox>("All sound overrides were reset."));
+		}
+	});
+	return codes;
+}
+
+void CodesFeedString(const QString &text) {
+	static const auto codes = GenerateCodes();
+	static auto secret = QString();
+
+	secret += text.toLower();
+	int size = secret.size(), from = 0;
+	while (size > from) {
+		auto piece = secret.midRef(from);
+		auto found = false;
+		for (const auto &[key, method] : codes) {
+			if (piece == key) {
+				method();
+				from = size;
+				found = true;
+				break;
+			}
+		}
+		if (found) break;
+
+		found = ranges::find_if(codes, [&](const auto &pair) {
+			return pair.first.startsWith(piece);
+		}) != end(codes);
+		if (found) break;
+
+		++from;
+	}
+	secret = (size > from) ? secret.mid(from) : QString();
+}
+
+} // namespace Settings
diff --git a/Telegram/SourceFiles/settings/settings_codes.h b/Telegram/SourceFiles/settings/settings_codes.h
new file mode 100644
index 000000000..27798adc5
--- /dev/null
+++ b/Telegram/SourceFiles/settings/settings_codes.h
@@ -0,0 +1,14 @@
+/*
+This file is part of Telegram Desktop,
+the official desktop application for the Telegram messaging service.
+
+For license and copyright information please follow this link:
+https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
+*/
+#pragma once
+
+namespace Settings {
+
+void CodesFeedString(const QString &text);
+
+} // namespace Settings
diff --git a/Telegram/SourceFiles/settings/settings_main.cpp b/Telegram/SourceFiles/settings/settings_main.cpp
index ca2840ac2..a9207a799 100644
--- a/Telegram/SourceFiles/settings/settings_main.cpp
+++ b/Telegram/SourceFiles/settings/settings_main.cpp
@@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 #include "settings/settings_main.h"
 
 #include "settings/settings_common.h"
+#include "settings/settings_codes.h"
 #include "boxes/abstract_box.h"
 #include "boxes/language_box.h"
 #include "boxes/confirm_box.h"
@@ -291,6 +292,11 @@ Main::Main(
 	setupContent(controller);
 }
 
+void Main::keyPressEvent(QKeyEvent *e) {
+	CodesFeedString(e->text());
+	return Section::keyPressEvent(e);
+}
+
 void Main::setupContent(not_null<Window::Controller*> controller) {
 	const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
 
diff --git a/Telegram/SourceFiles/settings/settings_main.h b/Telegram/SourceFiles/settings/settings_main.h
index 0a744b290..b98842661 100644
--- a/Telegram/SourceFiles/settings/settings_main.h
+++ b/Telegram/SourceFiles/settings/settings_main.h
@@ -28,6 +28,9 @@ public:
 
 	rpl::producer<Type> sectionShowOther() override;
 
+protected:
+	void keyPressEvent(QKeyEvent *e) override;
+
 private:
 	void setupContent(not_null<Window::Controller*> controller);
 
diff --git a/Telegram/gyp/telegram_sources.txt b/Telegram/gyp/telegram_sources.txt
index 60a03bce0..ec8ba4245 100644
--- a/Telegram/gyp/telegram_sources.txt
+++ b/Telegram/gyp/telegram_sources.txt
@@ -566,6 +566,8 @@
 <(src_loc)/old_settings/settings_widget.h
 <(src_loc)/settings/settings_chat.cpp
 <(src_loc)/settings/settings_chat.h
+<(src_loc)/settings/settings_codes.cpp
+<(src_loc)/settings/settings_codes.h
 <(src_loc)/settings/settings_common.cpp
 <(src_loc)/settings/settings_common.h
 <(src_loc)/settings/settings_general.cpp