has anyone got an idea on how to change letters on the keyboard around. i.e make Q on the keyboard print P on the screen.

Dani AI

Generated

clarified this is for a game, so the cleanest approach is to remap keys inside your game input layer rather than trying to change the system keyboard. and pointed toward simpler user-level fixes; below is an expert summary of safe, practical options and pitfalls to watch for.

The recommended solution: capture raw key events from your engine/library and translate them with a mapping table. This keeps remaps local to your game, avoids requiring admin access, and works across layouts if you map by physical scancode when needed. Example pattern (conceptual):

std::unordered_map<int,int> keymap = {{SDLK_q, SDLK_p}};

void onKeyDown(const SDL_Event& e) {
    int k = e.key.keysym.sym;
    int mapped = keymap.count(k) ? keymap[k] : k;
    // use 'mapped' for gameplay or text input
}

Notes and cautions:

  • Use scancodes when you want to remap physical key positions; use character/virtual-key codes when you want actual letters. Test with different keyboard layouts and IMEs (international input can behave differently).
  • System-wide techniques (OS layout changes, registry scancode map, or global hooks) will affect all apps, require higher privileges, and can cause compatibility or anti-cheat problems — avoid them for a game unless absolutely necessary.
  • Persist mappings to a simple config file and provide an in-game key-bind UI so players can customize and restore defaults.

This approach is portable, safe, and lets you implement features like per-player layouts, runtime toggles, and easy debugging without touching the OS.

Recommended Answers

All 3 Replies

Short of physically moving them... you could probably get your desired response by playing with getch() from <conio.h> ... not standard header though.

Do it the same way that I said you can change the mouse in your other thread. Seems like you are attempting to write a prank program ?????

no it's for a game i'm designing.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.