---
lang: en
title: 'API docs: context.filterbykey'
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
sidebar: lb4_sidebar
editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/context
permalink: /doc/en/lb4/apidocs.context.filterbykey.html
---

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@loopback/context](./context.md) &gt; [filterByKey](./context.filterbykey.md)

## filterByKey() function

Create a binding filter from key pattern

**Signature:**

```typescript
export declare function filterByKey(keyPattern?: string | RegExp | BindingFilter): BindingFilter;
```

## Parameters

<table><thead><tr><th>

Parameter


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td markdown="1">

keyPattern


</td><td markdown="1">

string \| RegExp \| [BindingFilter](./context.bindingfilter.md)


</td><td markdown="1">

_(Optional)_ Binding key/wildcard, regexp, or a filter function


</td></tr>
</tbody></table>

**Returns:**

[BindingFilter](./context.bindingfilter.md)


