making a keybind system, need help
Hello, so I am making a key bind system, as you can see on the image when user clicks the "bind" button, the textbox text right to it changes to that bind. How do I make it so there can not be duplicates? also I need to count for reverse because A+B is same as B+A also I need to exclude the current textbox from checking. And also what event should I use? If I use keydown then it will check every time so when I type A and then want to type A+B it wont let me because its checked on keydown. Please can anyone help I am out of ideas
10 Replies
where are you keeping the bindings? an array? a dictionary?
is it a class? a tuple? a record?
also can you have bindings in sequence, like say ctrl+a + b, or ctrl+a + shift+b, or are they single bindings
You can have ctrl+a+b yea but if you click ctrl last it will be a+b+ctrl tho
Nowhere, I will just read them off of a textbox and split by the + but idk how to make the binds not be able to be same
no i mean composite keypresses
like ctrl+a, release it, and then ctrl+b (or whatever)
wait, so no modifier? no ctrl alt shift?
You cand o ctrl+alt+shift yes
Can do*
Yea well no because I only need to press it once because I want to make a SA:MP keybinder so yea
I only coded the textbox part for now tho because I need to solve these duplicate issues
what do you mean by 'nowhere' 😐
well anyway you got the steps pretty much figured out: order doesn't count, exclude the textbox that is currently being edited
i don't understand what you mean with " it wont let me because its checked on keydown" tho
If i check the texboxes on k ydown event it will check everytime key is pressed so if i type A and then in other bind try to type A+ it wont let me because of A
I dont store bindings, I will read them off of a textbox and store them in a variable later
can you enter more in the details because it's unclear to me why such behavior would be a problem to solve
im just asking which event do I need to use? or how do I do it?
how would I solve it tho, im a beginner in c# so idk how
which event... i would probably make a settings page where formal verification is made on the closing OK button, maybe i would add real time check (non-blocking, just warnings) with key down or key press depending if i have to use modifiers or not
then i would create a kind of hash to make sure all bindings are unique, obviously characters in hash have to be independent of position so they could have a predefined one, like the alphabetical order
then put them all like in a hashset, if something crashes warn the user
there are really a lot of ways to do this
ok, I managed to do it one way but have a problem with returning the color once the keybind is right, can you help me in #problems with foreach loop it would be much appreciated
i did it using the keyup event tho
i didnt know it triggers only when all keys are up
if i knew that i would do it instantly