Files
Files copied to clipboard
Bug: Problem with mapping certain keys in action section
Description
I discovered a small bug where two characters are not displayed correctly:
-
KEY:
;wrong map to´; -
KEY:
)wrong map to¨)
but this problem is only in the text string representation, the KEY function is recorded correctly
Steps To Reproduce
- Fix string representations mapping this keys
Files Version
3.4.1.0
Windows Version
10.0.22631.3593
Log File
There are no errors
Fyi @0x5bfa
@XTorLukas thank you for the feedback. Aside from this issue, do you have any other thoughts or feedback on this feature?
@yaira2 Maybe I would like to be able to map also numeric keys e.g. Num0, Num1 and others and divide e.g. + and NumPlus
Thanks for the feedback!
It looks like your keyboard is not US keyboard, what keyboard type are you using? And, when you have a time to do, could you do that same in Windows Terminal > Settings > Actions? If it works well, it’s our problem, let me know:)
It looks like your keyboard is not US keyboard, what keyboard type are you using?
I use the Czech keyboard layout
And, when you have a time to do, could you do that same in Windows Terminal > Settings > Actions?
In other applications it works correctly
PowerToys
Terminal
Thanks! It looks like Files has an issue around humanizing input keys.
Maybe it will be useful.
I don't know how the implementation is used here, but I personally use this class:
public class KeyCodeConverter
{
[DllImport("user32.dll")]
private static extern int ToUnicode(
uint wVirtKey,
uint wScanCode,
byte[] lpKeyState,
[Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pwszBuff,
int cchBuff,
uint wFlags);
[DllImport("user32.dll")]
private static extern bool GetKeyboardState(byte[] lpKeyState);
[DllImport("user32.dll")]
private static extern uint MapVirtualKey(uint uCode, uint uMapType);
[DllImport("user32.dll")]
private static extern IntPtr GetKeyboardLayout(uint idThread);
public static char ConvertKeyCodeToChar(Keys key)
{
char ch = '\0';
byte[] keyboardState = new byte[256];
if (!GetKeyboardState(keyboardState))
{
return ch;
}
uint virtualKey = (uint)key;
uint scanCode = MapVirtualKey(virtualKey, 0);
StringBuilder stringBuilder = new StringBuilder(2);
int result = ToUnicode(virtualKey, scanCode, keyboardState, stringBuilder, stringBuilder.Capacity, 0);
if (result > 0)
{
ch = stringBuilder[0];
}
return ch;
}
Use in code
char character = KeyCodeConverter.ConvertKeyCodeToChar(keyData);
@yaira2 ToUnicode seems to be actually needed though I did remove. cinqmilleans's implementation is always correct...
I'll work on.
Thanks!
It looks like we didn't remove that ToUnicode line. I don't have a way to test.
@XTorLukas If you have a solution to this, do you wanna open a PR for this?
@0x5bfa I have my general solution, but I'm here for a short time and need time to get my head around the code, it's not easy with complex code.
But I'm certainly willing to help if I know the solution, just the correct implementation is important.
@XTorLukas thank you for your detailed report and fix!