This also happened to me, but I was able to work around it by switching to keyboard mode on the lock screen, typing the 4 numbers and then an additional character to activate the enter key, and trying to press backspace and enter simultaneously. If you’re lucky, the keyboard will register the enter key after the backspace key and the phone will unlock. You need to try this several times since it won’t always work.
After unlocking, you should change the code in settings. You will be prompted for the code again and this process needs to be repeated.