-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding shortcut keys to perform certain actions like Build , Pin/Unpin editor, Close/Open editor, Run and Reset #187
Comments
@meganindya In the last conversation we had you specified your concern about code editor being updated which might make any code I implement today irrelavent. At core to solve these problems we need to have all the shortcut keys and buttons linked to them in a single file. There might be a lot of eventlistener function running for a single click so rather that combining all those functions and runnig them when the shortcut key is pressed we could just emit a code flow -
above code follows js rules, while writing the actual code I'll make sure to write as per ts. having all shorcut keys in a single file and implementing emitevent as mentioned above, makes it easy to maintain and expand. @meganindya if everything is ok, I would like to start working on a PR for this |
@meganindya , After your previous Msg, I realized I need to make these shortcuts without id's of div rather use the reference of the button that we create when that button is initialized this will convert this into top down approach. and for achieving modularity we create a blank array above the code flow -
|
@meganindya After your Previous Message I think I understand how you want this project to be structured. You want to achieve complete modularity which means there shouldn't be any piece of code outside the module that manipulates elements of the current module without an interface or instructions present in the current module. You gave the example of mountHook(that stuff was great). I just need to create a function for running eventListener on windows to trigger shortcuts but lets other modules call this function and let them decide what shortcut to pass and what to do when that shortcut is run. Something similar to what you did with run and reset button with mountHook. code flow -
I think this should do the trick. |
@meganindya Last time we had a chat, you approved the above method but your problem was you didn't want to run a loop for executing the shortcuts because browsers might not handle loops very well. So we can create a hash map with key as Shortcut key and value as the list of call backs that'll run when the shortcut key is pressed .
I think you'll approve of this. |
I understand this but do discuss how you want to distribute/orchestrate the behaviour across components in general and code modules in specific |
When I proposed this idea, the main idea behind this was that the user doesn't have to use his mouse every time user run his code, using mouse becomes frustrating after few attempts. Unless we introduce drag and drop blocks, user will be able to perform every action with keyboard. Usually every browser has a lot of shortcuts predefined which we need to make sure not to use. "alt+any alphabet" seems to have no effect on browsers so I propose we use the combination of alt with alphabets, if the same alphabet needs to repeated we use shift+alt. @meganindya when we had a talk last time you specified having just The general idea behind making shortcut is, we have a hashmap with key values as shortcut key as "alt+a" and value will be array of functions that needs to run when that shortcut is triggered. we will have an interface function that will add shortcuts and functions into hashmap, this interface function can be used by components to add shortcuts and instructions on what to do. This way individual component has complete control on which shortcuts to add and what to do when shortcuts are run. after all the shortcuts and functions get added to hashmap we add an eventlistener on window and run all the functions of the array when a shortcut is triggered. Implementation -
I understand that there are gonna be lot of changes when code editor gets updated so for this pr i would like to create an interface function, eventlistener adding function and shortcuts just for code editor pin and unpin button as a POC I hope this comment makes everything clear. I'll think of better names for functions later(suggestions are welcome). |
Please make a POC of the framework. For now, just implement |
Discussed in #185
Originally posted by surajkumar-sk March 16, 2022
While learning about what different syntax does in musicblock v4 I had to edit and run the code a lot of times, I kept resetting the block and building the code for almost every 5 sec. It was fine moving my mouse to click the buttons in the beginning but after few attempts, It started getting frustrating to hover and click on build, run and reset. I as a Developer will probably not build, run and reset many times. Buts kids and teachers using this website might have to click on buttons more often. Adding shortcuts to buttons would make it easier to perform actions. we could add a hover text on buttons showing the shortcut keys. Changes in code wouldn't be much but adding this can make accessibility of buttons a lot easier for frequent learners or teachers.
shortcut for run - alt + r
shortcut for stop - alt + s
shortcut for reset - ctrl + alt + r
shortcut for opening or closing editor - ctrl + alt + e
shortcut for pin or unpin - alt + p
shortcut for build - alt + b
shortcut for help - alt + h
I would like to implement this changes as my
good first issue
and begin contributing to the project.The text was updated successfully, but these errors were encountered: