Please sign in to comment.
Solved keypress stuff for alg practice
This was kindof difficult, and in the end I'm not terribly happy with the solution, but in the end it does the trick. Basically, the idea is to attach/detach a global keydown handler when the alg practice component is shown/hidden. Since the component is being shown/hidden via `v-show`, and vue doesn't have any event to watch for when that changes, I decided to instead make a `show` prop that will both show/hide the component (so I also moved the `div` with `v-show` inside the component) and can be watched for changes. When changes occur, I can simply check if the new value was true/false, and attach/detach a keydown handler accordingly. It's one of those solutions that I don't really worry about in terms of robustness, but feels really roundabout and therefor hacky. However, it gets the job done, and it's relatively straightforward.
- Loading branch information...
Showing with 43 additions and 25 deletions.