You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 23, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Mar 23, 2026. It is now read-only.
Hi @EloB, I think this polyfill won't work with canvas/webGL.
In general, the polyfill moves the focus among focusable DOM elements. Therefore the canvas element will be considered as just one element, and the focus won't move inside it.
HTML5 canvas element doesn't remember contents drawn inside it. Most of JS libraries working with canvas element maintain there own data structure to remember what is drawn inside the canvas.
There are some complexities as below :
Focus: browser can focus element which is part of DOM only. (Let's say you can show focus ring using some canvas API)
Events: Focused element is not part of DOM so no browser events. (Let's say you don't need it. refer point 3)
Finding candidate node: You need logic to traverse and identify the element from(DOM + DS maintain by JS libraries). Even if you can do that, there is will be a lot of use cases related to Canvas which you need to handle.
If someone wants to use something like spatial navigation polyfill, you need to make a data structure for each object inside and make a virtual focus indicator by your own model. The spatial navigation polyfill could be referred to design the virtual focus management module triggered by the arrow key input.
You can have DOM elements inside your canvas and have them be focusable, but that is managing the focus manually via calling the focus method and the elements don't have layout so don't think that spatial nav would be able to help here.
Activity
[-]Can this be used with canvas/webgl?[/-][+]Can this be used with canvas/webgl/pixi.js?[/+]jihyerish commentedon Dec 2, 2019
Hi @EloB, I think this polyfill won't work with canvas/webGL.
In general, the polyfill moves the focus among focusable DOM elements. Therefore the canvas element will be considered as just one element, and the focus won't move inside it.
EloB commentedon Dec 3, 2019
I haven’t used the specification before. It won’t be extendable?
abhijeetk commentedon Dec 4, 2019
HTML5 canvas element doesn't remember contents drawn inside it. Most of JS libraries working with canvas element maintain there own data structure to remember what is drawn inside the canvas.
There are some complexities as below :
anawhj commentedon Dec 9, 2019
@abhijeetk, Great description!
If someone wants to use something like spatial navigation polyfill, you need to make a data structure for each object inside and make a virtual focus indicator by your own model. The spatial navigation polyfill could be referred to design the virtual focus management module triggered by the arrow key input.
Martin-Pitt commentedon Aug 5, 2023
You can have DOM elements inside your canvas and have them be focusable, but that is managing the focus manually via calling the focus method and the elements don't have layout so don't think that spatial nav would be able to help here.
See example on MDN: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/drawFocusIfNeeded