FileSystemDirectoryHandle: keys() method
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2023.
Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.
Note: This feature is available inWeb Workers.
Thekeys() method of theFileSystemDirectoryHandle interface returns a new asynchronous iteratorfor the iteration of the key of the entries within theFileSystemDirectoryHandleon which this method is called.
In this article
Syntax
keys()Parameters
None.
Return value
A new asynchronous iterator containing the keys of each entry within theFileSystemDirectoryHandle.
Exceptions
NotAllowedErrorDOMExceptionThrown if the
PermissionStatus.statefor the handle is not'granted'inreadmode.NotFoundErrorDOMExceptionThrown if the current entry is not found.
Examples
Use thefor await...of loop can simplify the iteration process.
const dirHandle = await window.showDirectoryPicker();for await (const key of dirHandle.keys()) { console.log(key);}Specifications
| Specification |
|---|
| File System> # api-filesystemdirectoryhandle-asynciterable> |