Open SpiralP opened 6 years ago
keyCode is deprecated, should probably use something else
Alright, I changed my code to use KeyboardEvent.key, but this always shows up as undefined
on Awesomium, and is still missing the same keys on Chromium(180801).
local a = vgui.Create("DHTML") timer.Simple(10, function() a:Remove() end)
a:SetPos(0, 0)
a:SetSize(200, 200)
a:SetHTML[[
<html><body style="background-color: white">
<script type="text/javascript">
document.onkeydown = function(e) { console.log("down " + e.key); };
document.onkeyup = function(e) { console.log("up " + e.key); };
document.onkeypress = function(e) { console.log("press " + e.key); };
</script>
</body></html>
]]
a:AddFunction("console", "log", chat.AddText)
a:SetVisible(true)
a:MakePopup()
Here's me pressing shift, control, windows key, alt, comma, /, then the m key
down Shift
up Shift
down Control
up Control
down Unidentified -- windows meta
up Unidentified
down Unidentified -- alt
up Unidentified
down Unidentified
press ,
up Unidentified
down Unidentified
press /
up Unidentified
down m
press m
up m
If the character you are trying to detect is displayable, the keypress event might work in your scenario (even though it is deprecated).
This is most annoying for the "escape" key. I have a HTML panel I need to hide when the user opens the menu/console. Otherwise, my panel displays on top of the menu, making the menu difficult to use.
On the Chromium branch, the
onkeydown
andonkeyup
events can't see the key code of symbol keys such as,./-=[];'
as well as alt and meta. These all come up as0
onevent.keyCode
.pressing and releasing shift, then the m key, then the , comma key
(note keydown/keyup vs keypress having different codes is normal, one shows the physical code and the other shows the character code)
We have an ingame editor on our server, and not being able to ctrl-/ line comment is annoying.
chromium/180331 Thanks again!