switching Keyboard laout (current window only)

I search the forum and i found bits and pieces on how to switch keyboard. right know i know that it is related to configuration in fvwm2rc and it effects the whole X.
But I want a config that confines the changes to the current window. and I can toggle between them by Alt+shift.

I do not think you can change the keyboard only for the current window, but you can probably change the keyboard layout with a Keyboard Shortcut using setxkbmap, like:

Key k A 4 Exec exec setxkbmap us key k A 4S Exec exec setxkbmap es

This will change to the ‘us’ keyboard with the “windows key” + 'k", and to the ‘es’ keyboard with the “windows key” + “shifht” + “k”. You can get more information about switching keyboards in your distribution documentation like, for example, wiki.gentoo.org/wiki/Keyboard_layout_switching


For switching keyboard layout for selected window only you can use kbdd (github.com/qnikst/kbdd)
Just add

setxkbmap -layout 'us,ru' -option 'grp:alt_shift_toggle' /usr/bin/kbdd
in your .xinitrc